@@ -7,14 +7,11 @@ import { createForm } from './formComponent';
7
7
import { UserAgreementStyle } from './formControlsComponent' ;
8
8
import { buildFormFields , type Field } from './formFieldFactory' ;
9
9
10
+ import { CaptchaProvider , WithCaptchaProps , type WithCaptchaToken } from '../../components/captcha' ;
10
11
import { snakeCaseProperties } from '../../helpers/transformObjectProperties' ;
11
12
import { isValued } from '../../helpers/utils' ;
12
13
import { MarkdownContent } from '../miscComponent' ;
13
- import ReCaptcha , {
14
- extractCaptchaTokenFromData ,
15
- importGoogleRecaptchaScript ,
16
- type WithCaptchaToken ,
17
- } from '../reCaptcha' ;
14
+ import { extractCaptchaTokenFromData , importGoogleRecaptchaScript } from '../reCaptcha' ;
18
15
19
16
import { useConfig } from '../../contexts/config' ;
20
17
import { useReachfive } from '../../contexts/reachfive' ;
@@ -33,8 +30,6 @@ export interface PasswordSignupFormProps {
33
30
beforeSignup ?: < T > ( param : T ) => T ;
34
31
canShowPassword ?: boolean ;
35
32
phoneNumberOptions ?: PhoneNumberOptions ;
36
- recaptcha_enabled ?: boolean ;
37
- recaptcha_site_key ?: string ;
38
33
redirectUrl ?: string ;
39
34
returnToAfterEmailConfirmation ?: string ;
40
35
showLabels ?: boolean ;
@@ -57,14 +52,17 @@ export const PasswordSignupForm = ({
57
52
phoneNumberOptions,
58
53
recaptcha_enabled = false ,
59
54
recaptcha_site_key,
55
+ captchaFoxEnabled = false ,
56
+ captchaFoxSiteKey,
57
+ captchaFoxMode = 'hidden' ,
60
58
redirectUrl,
61
59
returnToAfterEmailConfirmation,
62
60
showLabels,
63
61
signupFields = [ 'given_name' , 'family_name' , 'email' , 'password' , 'password_confirmation' ] ,
64
62
userAgreement,
65
63
onError = ( ( ) => { } ) as OnError ,
66
64
onSuccess = ( ( ) => { } ) satisfies OnSuccess ,
67
- } : PasswordSignupFormProps ) => {
65
+ } : WithCaptchaProps < PasswordSignupFormProps > ) => {
68
66
const coreClient = useReachfive ( ) ;
69
67
const config = useConfig ( ) ;
70
68
const [ blacklist , setBlacklist ] = useState < string [ ] > ( [ ] ) ;
@@ -128,28 +126,30 @@ export const PasswordSignupForm = ({
128
126
: fields ;
129
127
130
128
return (
131
- < SignupForm
132
- fields = { allFields }
133
- showLabels = { showLabels }
134
- beforeSubmit = { beforeSignup }
135
- onFieldChange = { refreshBlacklist }
136
- sharedProps = { {
137
- blacklist,
138
- ...phoneNumberOptions ,
139
- } }
140
- handler = { ( data : SignupParams [ 'data' ] ) =>
141
- ReCaptcha . handle (
142
- data ,
143
- { recaptcha_enabled, recaptcha_site_key } ,
144
- callback ,
145
- 'signup'
146
- )
147
- }
148
- onSuccess = { authResult => {
149
- onSuccess ( { name : 'signup' , authResult } ) ;
150
- } }
151
- onError = { onError }
152
- />
129
+ < CaptchaProvider
130
+ recaptcha_enabled = { recaptcha_enabled }
131
+ recaptcha_site_key = { recaptcha_site_key }
132
+ captchaFoxEnabled = { captchaFoxEnabled }
133
+ captchaFoxSiteKey = { captchaFoxSiteKey }
134
+ captchaFoxMode = { captchaFoxMode }
135
+ action = "signup"
136
+ >
137
+ < SignupForm
138
+ fields = { allFields }
139
+ showLabels = { showLabels }
140
+ beforeSubmit = { beforeSignup }
141
+ onFieldChange = { refreshBlacklist }
142
+ sharedProps = { {
143
+ blacklist,
144
+ ...phoneNumberOptions ,
145
+ } }
146
+ handler = { callback }
147
+ onSuccess = { authResult => {
148
+ onSuccess ( { name : 'signup' , authResult } ) ;
149
+ } }
150
+ onError = { onError }
151
+ />
152
+ </ CaptchaProvider >
153
153
) ;
154
154
} ;
155
155
0 commit comments