From 1b10204c586bab763529bf1ef6a7f1a31bfede75 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 14 Apr 2023 12:18:39 +0530 Subject: [PATCH] fix recover flow caused leading user to gallery even if he is on auth app --- src/components/SetPasswordForm.tsx | 1 - src/constants/apps/index.ts | 1 + src/pages/change-password/index.tsx | 30 +++++++++++++++-------------- src/pages/generate/index.tsx | 8 +++++++- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/components/SetPasswordForm.tsx b/src/components/SetPasswordForm.tsx index 9b47bf1f5..14d0b66a5 100644 --- a/src/components/SetPasswordForm.tsx +++ b/src/components/SetPasswordForm.tsx @@ -19,7 +19,6 @@ export interface SetPasswordFormProps { ) => void ) => Promise; buttonText: string; - back: () => void; } export interface SetPasswordFormValues { passphrase: string; diff --git a/src/constants/apps/index.ts b/src/constants/apps/index.ts index 49ac09a95..1c8c1502a 100644 --- a/src/constants/apps/index.ts +++ b/src/constants/apps/index.ts @@ -19,6 +19,7 @@ export const ALLOWED_APP_PAGES = new Map([ PAGES.VERIFY, PAGES.CREDENTIALS, PAGES.RECOVER, + PAGES.CHANGE_PASSWORD, PAGES.GENERATE, PAGES.AUTH, PAGES.TWO_FACTOR_VERIFY, diff --git a/src/pages/change-password/index.tsx b/src/pages/change-password/index.tsx index e44248cba..f287528bf 100644 --- a/src/pages/change-password/index.tsx +++ b/src/pages/change-password/index.tsx @@ -21,6 +21,7 @@ import FormPaper from 'components/Form/FormPaper'; import FormPaperFooter from 'components/Form/FormPaper/Footer'; import FormPaperTitle from 'components/Form/FormPaper/Title'; import ComlinkCryptoWorker from 'utils/comlink/ComlinkCryptoWorker'; +import { APPS, getAppName } from 'constants/apps'; export default function ChangePassword() { const [token, setToken] = useState(); @@ -74,12 +75,17 @@ export default function ChangePassword() { ); await saveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, key); - redirectToGallery(); + redirectToAppHome(); }; - const redirectToGallery = () => { + const redirectToAppHome = () => { setData(LS_KEYS.SHOW_BACK_BUTTON, { value: true }); - router.push(PAGES.GALLERY); + const appName = getAppName(); + if (appName === APPS.AUTH) { + router.push(PAGES.AUTH); + } else { + router.push(PAGES.GALLERY); + } }; return ( @@ -90,18 +96,14 @@ export default function ChangePassword() { userEmail={user?.email} callback={onSubmit} buttonText={t('CHANGE_PASSWORD')} - back={ - getData(LS_KEYS.SHOW_BACK_BUTTON)?.value - ? redirectToGallery - : null - } /> - - - - {t('GO_BACK')} - - + {getData(LS_KEYS.SHOW_BACK_BUTTON)?.value && ( + + + {t('GO_BACK')} + + + )} ); diff --git a/src/pages/generate/index.tsx b/src/pages/generate/index.tsx index 87e8576ca..8a22c156c 100644 --- a/src/pages/generate/index.tsx +++ b/src/pages/generate/index.tsx @@ -23,6 +23,8 @@ import FormContainer from 'components/Form/FormContainer'; import FormPaper from 'components/Form/FormPaper'; import FormTitle from 'components/Form/FormPaper/Title'; import { APPS, getAppName } from 'constants/apps'; +import FormPaperFooter from 'components/Form/FormPaper/Footer'; +import LinkButton from 'components/pages/gallery/LinkButton'; export default function Generate() { const [token, setToken] = useState(); @@ -117,8 +119,12 @@ export default function Generate() { userEmail={user?.email} callback={onSubmit} buttonText={t('SET_PASSPHRASE')} - back={logoutUser} /> + + + {t('GO_BACK')} + + )}