UserPasswordReset: Handle 'Cancel' and 'X' for the direct entry scenario.

The `UserPasswordReset` can be accessed in two places:
(1) While signing in
(2) From the Settings Page when changing password.

This commit:
- maintains the existing `Cancel|X` behavior for case-1, which is to remain in the Sign-in page.
- For case-2 and any future direct-entry, we'll simply call `goBack()`.
This commit is contained in:
infiinte-persistence 2020-07-07 17:47:52 +08:00 committed by Sean Yesmunt
parent 3f8d447b2a
commit 9389b61f02
2 changed files with 12 additions and 2 deletions

View file

@ -78,6 +78,7 @@ const Header = (props: Props) => {
const isVerifyPage = history.location.pathname.includes(PAGES.AUTH_VERIFY);
const isSignUpPage = history.location.pathname.includes(PAGES.AUTH);
const isSignInPage = history.location.pathname.includes(PAGES.AUTH_SIGNIN);
const isPwdResetPage = history.location.pathname.includes(PAGES.AUTH_PASSWORD_RESET);
// Sign out if they click the "x" when they are on the password prompt
const authHeaderAction = syncError ? { onClick: signOut } : { navigate: '/' };
@ -95,6 +96,10 @@ const Header = (props: Props) => {
history.goBack();
}
if (isPwdResetPage) {
history.goBack();
}
if (syncError) {
signOut();
}

View file

@ -33,9 +33,10 @@ function UserPasswordReset(props: Props) {
doClearEmailEntry,
emailToVerify,
} = props;
const { push } = useHistory();
const { location, push, goBack } = useHistory();
const [email, setEmail] = React.useState(emailToVerify || '');
const valid = email.match(EMAIL_REGEX);
const restartAtSignInPage = location.pathname === `/$/${PAGES.AUTH_SIGNIN}`;
function handleSubmit() {
if (email) {
@ -47,7 +48,11 @@ function UserPasswordReset(props: Props) {
setEmail('');
doClearPasswordEntry();
doClearEmailEntry();
if (restartAtSignInPage) {
push(`/$/${PAGES.AUTH_SIGNIN}`);
} else {
goBack();
}
}
React.useEffect(() => {