Skip to content

Commit a929a2d

Browse files
authored
Merge pull request #18157 from mozilla/FXA-10876
fix(settings): Get email from account hook instead of location state
2 parents 742ac01 + 1d3aa4b commit a929a2d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

  • packages/fxa-settings/src/pages/ResetPassword/ResetPasswordWithRecoveryKeyVerified

packages/fxa-settings/src/pages/ResetPassword/ResetPasswordWithRecoveryKeyVerified/container.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
import { useCallback, useEffect, useState } from 'react';
6-
import { RouteComponentProps, useLocation } from '@reach/router';
6+
import { RouteComponentProps } from '@reach/router';
77
import { ResetPasswordWithRecoveryKeyVerifiedProps } from './interfaces';
88
import { formatRecoveryKey } from '../../../lib/utilities';
99
import { 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

Comments
 (0)