homeflowjs 0.13.54 → 0.13.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/recaptcha.js
CHANGED
@@ -60,46 +60,65 @@ export default () => {
|
|
60
60
|
}
|
61
61
|
}
|
62
62
|
|
63
|
-
|
64
|
-
const invisibleRecaptcha = document.createElement('div');
|
65
|
-
invisibleRecaptcha.classList.add('g-recaptcha');
|
66
|
-
invisibleRecaptcha.dataset.sitekey = '6Lf16S0UAAAAAL0YaWCLRhChd4Uk77b-4Ai0ZdRY';
|
67
|
-
invisibleRecaptcha.dataset.callback = 'submitRecaptchaForm';
|
68
|
-
invisibleRecaptcha.dataset.size = 'invisible';
|
69
|
-
|
63
|
+
const appendRecaptchaScript = () => {
|
70
64
|
const recaptchaScript = document.createElement('script');
|
71
65
|
recaptchaScript.src = 'https://www.google.com/recaptcha/api.js';
|
72
66
|
recaptchaScript.id = 'recaptcha-script';
|
73
67
|
|
68
|
+
document.body.appendChild(recaptchaScript);
|
69
|
+
}
|
70
|
+
|
71
|
+
const onRecaptchaReady = (formSelectors) => {
|
72
|
+
if (window.recaptchaLoadingScriptInterval) {
|
73
|
+
clearTimeout(window.recaptchaLoadingScriptInterval);
|
74
|
+
window.recaptchaLoadingScriptInterval = undefined;
|
75
|
+
}
|
76
|
+
|
74
77
|
const forms = document.querySelectorAll(formSelectors.join(', '));
|
75
|
-
forms.forEach((form) => {
|
76
|
-
form.appendChild(invisibleRecaptcha);
|
77
|
-
});
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
79
|
+
forms.forEach((form, i) => {
|
80
|
+
const formRecaptchaWrapper = document.createElement('div');
|
81
|
+
formRecaptchaWrapper.id = `recaptcha-wrapper-${i}`;
|
82
|
+
|
83
|
+
form.appendChild(formRecaptchaWrapper);
|
84
|
+
|
85
|
+
const onRecaptchaSubmit = () => {
|
86
|
+
form.submit();
|
87
|
+
Homeflow.kickEvent('after_successful_recaptcha', form);
|
88
|
+
}
|
89
|
+
|
90
|
+
const widget = window.grecaptcha.render(`recaptcha-wrapper-${i}`, {
|
91
|
+
sitekey: '6Lf16S0UAAAAAL0YaWCLRhChd4Uk77b-4Ai0ZdRY',
|
92
|
+
callback: onRecaptchaSubmit,
|
93
|
+
size: 'invisible',
|
88
94
|
});
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
window.widgetIds = window.widgetIds
|
97
|
+
? [...window.widgetIds, widget]
|
98
|
+
: [widget]
|
99
|
+
|
100
|
+
form.addEventListener('submit', (e) => {
|
101
|
+
if (e.target.classList.contains('hfjs-form-invalid')) {
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
|
105
|
+
e.preventDefault();
|
106
|
+
Homeflow.set('submitted_form', e.target);
|
107
|
+
grecaptcha.execute(widget);
|
101
108
|
});
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
function addRecaptchaV2(formSelectors) {
|
113
|
+
if (!document.getElementById('recaptcha-script')) {
|
114
|
+
appendRecaptchaScript();
|
102
115
|
}
|
116
|
+
|
117
|
+
window.recaptchaLoadingScriptInterval = setInterval(() => {
|
118
|
+
if (window.grecaptcha?.render) {
|
119
|
+
onRecaptchaReady(formSelectors)
|
120
|
+
}
|
121
|
+
}, 300);
|
103
122
|
}
|
104
123
|
|
105
124
|
if (Homeflow.get('recaptcha_version') === 3) {
|
package/package.json
CHANGED
@@ -3,14 +3,34 @@ import PropTypes from 'prop-types';
|
|
3
3
|
|
4
4
|
import notify from '../../app/notify';
|
5
5
|
|
6
|
-
const ForgottenPasswordForm = ({
|
6
|
+
const ForgottenPasswordForm = ({
|
7
|
+
inputClass,
|
8
|
+
buttonClass,
|
9
|
+
buttonSpanClass,
|
10
|
+
honeypot,
|
11
|
+
honeypotClass,
|
12
|
+
}) => {
|
7
13
|
const [email, setEmail] = useState('');
|
14
|
+
const [honeypotInput, setHoneypotInput] = useState('');
|
8
15
|
const [success, setSuccess] = useState(false);
|
9
16
|
|
17
|
+
const fallbackHoneypotStyles = {
|
18
|
+
display: 'block',
|
19
|
+
width: 0,
|
20
|
+
height: 0,
|
21
|
+
padding: 0,
|
22
|
+
border: 0,
|
23
|
+
opacity: 0,
|
24
|
+
fontSize: 0,
|
25
|
+
color: 'transparent',
|
26
|
+
};
|
27
|
+
|
10
28
|
const handleSubmit = (e) => {
|
11
29
|
e.preventDefault();
|
12
30
|
|
13
31
|
const formData = new FormData();
|
32
|
+
if (honeypotInput !== '') return window.location.href = '/';
|
33
|
+
|
14
34
|
formData.append('email', email);
|
15
35
|
|
16
36
|
fetch('/reset_passwords', {
|
@@ -39,6 +59,18 @@ const ForgottenPasswordForm = ({ inputClass, buttonClass, buttonSpanClass }) =>
|
|
39
59
|
|
40
60
|
return (
|
41
61
|
<form className="forgotten-password-form" onSubmit={handleSubmit}>
|
62
|
+
{honeypot && (
|
63
|
+
<input
|
64
|
+
className={honeypotClass || null}
|
65
|
+
style={honeypotClass ? null : fallbackHoneypotStyles}
|
66
|
+
type="text"
|
67
|
+
id="body"
|
68
|
+
name="body"
|
69
|
+
value={honeypotInput}
|
70
|
+
onChange={(e) => setHoneypotInput(e.target.value)}
|
71
|
+
/>
|
72
|
+
)}
|
73
|
+
|
42
74
|
<p>Enter your email address and we'll send you a link to reset your password.</p>
|
43
75
|
|
44
76
|
<input
|
@@ -65,12 +97,16 @@ ForgottenPasswordForm.propTypes = {
|
|
65
97
|
inputClass: PropTypes.string,
|
66
98
|
buttonClass: PropTypes.string,
|
67
99
|
buttonSpanClass: PropTypes.string,
|
100
|
+
honeypot: PropTypes.bool,
|
101
|
+
honeypotClass: PropTypes.string,
|
68
102
|
};
|
69
103
|
|
70
104
|
ForgottenPasswordForm.defaultProps = {
|
71
105
|
inputClass: '',
|
72
106
|
buttonClass: '',
|
73
107
|
buttonSpanClass: '',
|
108
|
+
honeypot: false,
|
109
|
+
honeypotClass: '',
|
74
110
|
};
|
75
111
|
|
76
112
|
export default ForgottenPasswordForm;
|
@@ -28,8 +28,13 @@ const UserRegisterForm = (props) => {
|
|
28
28
|
|
29
29
|
const handleSubmit = (e) => {
|
30
30
|
e.preventDefault();
|
31
|
+
const { body } = Object.fromEntries(new FormData(e.target));
|
32
|
+
const formData = {
|
33
|
+
...localUser,
|
34
|
+
body,
|
35
|
+
};
|
31
36
|
|
32
|
-
const userParams = doNotContact ? { ...
|
37
|
+
const userParams = doNotContact ? { ...formData, do_not_contact: 1 } : formData;
|
33
38
|
userParams.marketing_preferences = {
|
34
39
|
...localUser.marketing_preferences, opt_in_marketing_statement: marketingStatement,
|
35
40
|
};
|
@@ -58,6 +63,11 @@ const UserRegisterForm = (props) => {
|
|
58
63
|
|
59
64
|
return (
|
60
65
|
<form onSubmit={handleSubmit} {...otherProps}>
|
66
|
+
<input
|
67
|
+
type="text"
|
68
|
+
name="body"
|
69
|
+
style={{ height: 0, width: 0, opacity: 0 }}
|
70
|
+
/>
|
61
71
|
{children}
|
62
72
|
</form>
|
63
73
|
);
|