Skip to content

Commit 4c7d62d

Browse files
committed
fix(session): Add session verified guard to change password page
Because: * Users with an unverified session can click into change password without being prompted with the session verify modal. They'd get an 'Unconfirmed session' error message on submission with no way to rectify This commit: * Adds the guard fixes FXA-12410
1 parent 42b85b1 commit 4c7d62d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • packages/fxa-settings/src/components/Settings/PageChangePassword

packages/fxa-settings/src/components/Settings/PageChangePassword/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
getErrorFtlId,
2222
getLocalizedErrorMessage,
2323
} from '../../../lib/error-utils';
24+
import VerifiedSessionGuard from '../VerifiedSessionGuard';
2425

2526
type FormData = {
2627
oldPassword: string;
@@ -57,12 +58,20 @@ export const PageChangePassword = ({}: RouteComponentProps) => {
5758
useState<string>();
5859
const [newPasswordErrorText, setNewPasswordErrorText] = useState<string>();
5960

61+
const goHome = useCallback(
62+
() =>
63+
navigateWithQuery(SETTINGS_PATH + '#password', {
64+
replace: true,
65+
}),
66+
[navigateWithQuery]
67+
);
68+
6069
const alertSuccessAndGoHome = useCallback(() => {
6170
alertBar.success(
6271
ftlMsgResolver.getMsg('pw-change-success-alert-2', 'Password updated')
6372
);
64-
navigateWithQuery(SETTINGS_PATH + '#password', { replace: true });
65-
}, [alertBar, ftlMsgResolver, navigateWithQuery]);
73+
goHome();
74+
}, [alertBar, ftlMsgResolver, goHome]);
6675

6776
const onFormSubmit = useCallback(
6877
async ({ oldPassword, newPassword }: FormData) => {
@@ -102,6 +111,7 @@ export const PageChangePassword = ({}: RouteComponentProps) => {
102111
return (
103112
<Localized id="pw-change-header" attrs={{ title: true }}>
104113
<FlowContainer title="Change password">
114+
<VerifiedSessionGuard onDismiss={goHome} onError={goHome} />
105115
<FormPassword
106116
{...{
107117
formState,

0 commit comments

Comments
 (0)