File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed
packages/clerk-js/src/core/resources Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ---
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export class Environment extends BaseResource implements EnvironmentResource {
3333 this . fromJSON ( data ) ;
3434 }
3535
36- fetch ( { touch = false } : { touch : boolean } ) : Promise < Environment > {
36+ fetch ( { touch } : { touch : boolean } = { touch : false } ) : Promise < Environment > {
3737 if ( touch ) {
3838 return this . _basePatch ( { } ) ;
3939 }
Original file line number Diff line number Diff line change @@ -260,15 +260,23 @@ export class SignUp extends BaseResource implements SignUpResource {
260260 } : AuthenticateWithRedirectParams & {
261261 unsafeMetadata ?: SignUpUnsafeMetadata ;
262262 } ) : Promise < void > => {
263- const authenticateFn = ( args : SignUpCreateParams | SignUpUpdateParams ) =>
264- continueSignUp && this . id ? this . update ( args ) : this . create ( args ) ;
265-
266- const { verifications } = await authenticateFn ( {
267- strategy,
268- redirectUrl : SignUp . clerk . buildUrlWithAuth ( redirectUrl ) ,
269- actionCompleteRedirectUrl : redirectUrlComplete ,
270- unsafeMetadata,
271- emailAddress,
263+ const authenticateFn = ( ) => {
264+ const params = {
265+ strategy,
266+ redirectUrl : SignUp . clerk . buildUrlWithAuth ( redirectUrl ) ,
267+ actionCompleteRedirectUrl : redirectUrlComplete ,
268+ unsafeMetadata,
269+ emailAddress,
270+ } ;
271+ return continueSignUp && this . id ? this . update ( params ) : this . create ( params ) ;
272+ } ;
273+
274+ const { verifications } = await authenticateFn ( ) . catch ( async ( ) => {
275+ // If captcha verification failed because the environment has changed, we need
276+ // to reload the environment and try again one more time with the new environment.
277+ // If this fails again, we will let the caller handle the error accordingly.
278+ await SignUp . clerk . __unstable__environment ! . reload ( ) ;
279+ return authenticateFn ( ) ;
272280 } ) ;
273281
274282 const { externalAccount } = verifications ;
You can’t perform that action at this time.
0 commit comments