@@ -63,31 +63,36 @@ function PasskeyRecoverAccountWithTokenTheme(props: RecoverAccountWithTokenTheme
6363 return ;
6464 }
6565
66- const registerOptions = await props . recipeImplementation . getRegisterOptions ( {
67- userContext : props . userContext ,
68- recoverAccountToken : props . token ,
69- } ) ;
70- if ( registerOptions . status !== "OK" ) {
71- switch ( registerOptions . status ) {
72- case "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" :
73- setErrorMessageLabel ( "WEBAUTHN_ACCOUNT_RECOVERY_TOKEN_INVALID_ERROR" ) ;
74- break ;
75- case "INVALID_EMAIL_ERROR" :
76- setErrorMessageLabel ( "WEBAUTHN_ACCOUNT_RECOVERY_INVALID_EMAIL_ERROR" ) ;
77- break ;
78- case "INVALID_GENERATED_OPTIONS_ERROR" :
79- setErrorMessageLabel ( "WEBAUTHN_ACCOUNT_RECOVERY_INVALID_GENERATED_OPTIONS_ERROR" ) ;
80- // TODO: Should we trigger an automatic retry here or will there
81- // be a separate expired token related error?
82- break ;
83- default :
84- throw new Error ( "Should never come here" ) ;
66+ try {
67+ const registerOptions = await props . recipeImplementation . getRegisterOptions ( {
68+ userContext : props . userContext ,
69+ recoverAccountToken : props . token ,
70+ } ) ;
71+ if ( registerOptions . status !== "OK" ) {
72+ switch ( registerOptions . status ) {
73+ case "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" :
74+ setErrorMessageLabel ( "WEBAUTHN_ACCOUNT_RECOVERY_TOKEN_INVALID_ERROR" ) ;
75+ break ;
76+ case "INVALID_EMAIL_ERROR" :
77+ setErrorMessageLabel ( "WEBAUTHN_ACCOUNT_RECOVERY_INVALID_EMAIL_ERROR" ) ;
78+ break ;
79+ case "INVALID_GENERATED_OPTIONS_ERROR" :
80+ setErrorMessageLabel ( "WEBAUTHN_ACCOUNT_RECOVERY_INVALID_GENERATED_OPTIONS_ERROR" ) ;
81+ // TODO: Should we trigger an automatic retry here or will there
82+ // be a separate expired token related error?
83+ break ;
84+ default :
85+ throw new Error ( "Should never come here" ) ;
86+ }
87+
88+ return ;
8589 }
8690
87- return ;
91+ setRegisterOptions ( registerOptions ) ;
92+ } catch ( err : any ) {
93+ // This will likely be a fetch error.
94+ setErrorMessageLabel ( "WEBAUTHN_ACCOUNT_RECOVERY_FETCH_ERROR" ) ;
8895 }
89-
90- setRegisterOptions ( registerOptions ) ;
9196 } , [ props ] ) ;
9297
9398 useEffect ( ( ) => {
@@ -135,6 +140,7 @@ function PasskeyRecoverAccountWithTokenTheme(props: RecoverAccountWithTokenTheme
135140 onContinueClick = { onContinueClick }
136141 errorMessageLabel = { errorMessageLabel }
137142 email = { registerOptions ?. user . name || null }
143+ isContinueDisabled = { registerOptions === null }
138144 />
139145 { activeScreen !== RecoverAccountScreen . Success && (
140146 < AuthPageFooter
@@ -159,16 +165,18 @@ const RecoverAccountThemeInner = (
159165 onContinueClick : ( ) => void ;
160166 errorMessageLabel : string | null ;
161167 email : string | null ;
168+ isContinueDisabled : boolean ;
162169 }
163170) => {
164171 return props . activeScreen === RecoverAccountScreen . ContinueWithPasskey ? (
165172 < PasskeyConfirmation
166173 { ...props }
167- email = { props . email || "" }
174+ email = { props . email || undefined }
168175 onContinueClick = { props . onContinueClick }
169176 errorMessageLabel = { props . errorMessageLabel || undefined }
170177 isLoading = { false }
171178 hideContinueWithoutPasskey
179+ isContinueDisabled = { props . isContinueDisabled }
172180 />
173181 ) : props . activeScreen === RecoverAccountScreen . Success ? (
174182 < PasskeyRecoverAccountSuccess />
0 commit comments