@@ -343,9 +343,16 @@ function useOnLoad(
343343 accessDenied : true ,
344344 error : "SOMETHING_WENT_WRONG_ERROR_RELOAD" ,
345345 } ) ;
346+ return ;
346347 }
347348 }
348349
350+ const alreadySetup = mfaInfo . factors . alreadySetup . includes ( FactorIds . WEBAUTHN ) ;
351+ if ( alreadySetup ) {
352+ dispatch ( { type : "setError" , accessDenied : true , error : "SOMETHING_WENT_WRONG_ERROR_RELOAD" } ) ;
353+ return ;
354+ }
355+
349356 // If the next array only has a single option, it means the we were redirected here
350357 // automatically during the sign in process. In that case, anywhere the back button
351358 // could go would redirect back here, making it useless.
@@ -357,16 +364,19 @@ function useOnLoad(
357364 const mfaInfoEmails = mfaInfo . emails [ FactorIds . WEBAUTHN ] ;
358365 const email = mfaInfoEmails ? mfaInfoEmails [ 0 ] : undefined ;
359366
360- const browserSupportsWebauthn = await props . recipe . webJSRecipe . doesBrowserSupportWebAuthn ( {
367+ const browserSupportsWebauthnResponse = await props . recipe . webJSRecipe . doesBrowserSupportWebAuthn ( {
361368 userContext : userContext ,
362369 } ) ;
370+ const browserSupportsWebauthn =
371+ browserSupportsWebauthnResponse . status === "OK" &&
372+ browserSupportsWebauthnResponse ?. browserSupportsWebauthn ;
363373
364374 dispatch ( {
365375 type : "load" ,
366376 error,
367377 showBackButton,
368378 email,
369- deviceSupported : browserSupportsWebauthn . status === "OK" ,
379+ deviceSupported : browserSupportsWebauthn ,
370380 } ) ;
371381 } ,
372382 [ dispatch , recipeImplementation , props . recipe , userContext ]
0 commit comments