33 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
55import { useCallback , useEffect , useState } from 'react' ;
6- import { RouteComponentProps , useLocation } from '@reach/router' ;
6+ import { RouteComponentProps } from '@reach/router' ;
77import { ResetPasswordWithRecoveryKeyVerifiedProps } from './interfaces' ;
88import { formatRecoveryKey } from '../../../lib/utilities' ;
99import { useNavigateWithQuery } from '../../../lib/hooks/useNavigateWithQuery' ;
@@ -32,9 +32,6 @@ const ResetPasswordWithRecoveryKeyVerifiedContainer = ({
3232 const navigateWithQuery = useNavigateWithQuery ( ) ;
3333 const sensitiveDataClient = useSensitiveDataClient ( ) ;
3434
35- const location = useLocation ( ) ;
36- const { email } = location . state as Record < string , string > ;
37-
3835 const authClient = useAuthClient ( ) ;
3936 const { finishOAuthFlowHandler } = useFinishOAuthFlowHandler (
4037 authClient ,
@@ -44,7 +41,7 @@ const ResetPasswordWithRecoveryKeyVerifiedContainer = ({
4441 useState < FinishOAuthFlowHandlerResult [ 'error' ] > ( ) ;
4542
4643 const account = useAccount ( ) ;
47- const { uid, sessionToken } = currentAccount ( ) || { } ;
44+ const { uid, sessionToken, email } = currentAccount ( ) || { } ;
4845 const updateRecoveryKeyHint = useCallback (
4946 async ( hint : string ) => account . updateRecoveryKeyHint ( hint ) ,
5047 [ account ]
@@ -56,16 +53,19 @@ const ResetPasswordWithRecoveryKeyVerifiedContainer = ({
5653 ) ?. recoveryKey ;
5754
5855 useEffect ( ( ) => {
56+ if ( ! email ) {
57+ navigateWithQuery ( '/signin' , { replace : true } ) ;
58+ }
5959 if ( ! recoveryKey ) {
6060 // If we get here, that means a password reset was completed (with a verified account).
6161 // Along the way, we have lost a copy of the recovery key in memory if the page was unloaded.
6262 // This is fine - we navigate to the confirmed page and carry on.
6363 navigateWithQuery ( '/reset_password_verified' , { replace : true } ) ;
6464 }
65- } , [ recoveryKey , navigateWithQuery ] ) ;
65+ } , [ recoveryKey , email , navigateWithQuery ] ) ;
6666
67- if ( ! recoveryKey ) {
68- return ;
67+ if ( ! recoveryKey || ! email ) {
68+ return < > </ > ;
6969 }
7070
7171 const newRecoveryKey = formatRecoveryKey ( recoveryKey . buffer ) ;
0 commit comments