From 9389b61f026d481e627de3881602fc3743a04541 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Tue, 7 Jul 2020 17:47:52 +0800 Subject: [PATCH] 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()`. --- ui/component/header/view.jsx | 5 +++++ ui/component/userPasswordReset/view.jsx | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ui/component/header/view.jsx b/ui/component/header/view.jsx index 0024ddb83..82399819f 100644 --- a/ui/component/header/view.jsx +++ b/ui/component/header/view.jsx @@ -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(); } diff --git a/ui/component/userPasswordReset/view.jsx b/ui/component/userPasswordReset/view.jsx index 626110ea6..0825992d0 100644 --- a/ui/component/userPasswordReset/view.jsx +++ b/ui/component/userPasswordReset/view.jsx @@ -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(); - push(`/$/${PAGES.AUTH_SIGNIN}`); + if (restartAtSignInPage) { + push(`/$/${PAGES.AUTH_SIGNIN}`); + } else { + goBack(); + } } React.useEffect(() => {