diff --git a/web/packages/accounts/components/ChangeEmail.tsx b/web/packages/accounts/components/ChangeEmail.tsx index 6c76d644a..bb29893bf 100644 --- a/web/packages/accounts/components/ChangeEmail.tsx +++ b/web/packages/accounts/components/ChangeEmail.tsx @@ -68,7 +68,8 @@ function ChangeEmailForm({ appName }: PageProps) { }; const goToApp = () => { - router.push(APP_HOMES.get(appName)); + // TODO: Refactor the type of APP_HOMES to not require the ?? + router.push(APP_HOMES.get(appName) ?? "/"); }; return ( diff --git a/web/packages/accounts/pages/change-password.tsx b/web/packages/accounts/pages/change-password.tsx index 1696c5b9f..24617cb46 100644 --- a/web/packages/accounts/pages/change-password.tsx +++ b/web/packages/accounts/pages/change-password.tsx @@ -121,7 +121,8 @@ export default function ChangePassword({ appName }: PageProps) { const redirectToAppHome = () => { setData(LS_KEYS.SHOW_BACK_BUTTON, { value: true }); - router.push(APP_HOMES.get(appName)); + // TODO: Refactor the type of APP_HOMES to not require the ?? + router.push(APP_HOMES.get(appName) ?? "/"); }; return ( diff --git a/web/packages/accounts/pages/credentials.tsx b/web/packages/accounts/pages/credentials.tsx index 6ef39c7c7..5da52ac02 100644 --- a/web/packages/accounts/pages/credentials.tsx +++ b/web/packages/accounts/pages/credentials.tsx @@ -86,7 +86,8 @@ export default function Credentials({ appContext, appName }: PageProps) { } const token = getToken(); if (key && token) { - router.push(APP_HOMES.get(appName)); + // TODO: Refactor the type of APP_HOMES to not require the ?? + router.push(APP_HOMES.get(appName) ?? "/"); return; } const kekEncryptedAttributes: B64EncryptionResult = getKey( diff --git a/web/packages/accounts/pages/generate.tsx b/web/packages/accounts/pages/generate.tsx index e9ad433d5..21c803bc6 100644 --- a/web/packages/accounts/pages/generate.tsx +++ b/web/packages/accounts/pages/generate.tsx @@ -1,4 +1,5 @@ import log from "@/next/log"; +import { ensure } from "@/utils/ensure"; import { putAttributes } from "@ente/accounts/api/user"; import SetPasswordForm, { type SetPasswordFormProps, @@ -55,7 +56,8 @@ export default function Generate({ appContext, appName }: PageProps) { setRecoveryModalView(true); setLoading(false); } else { - router.push(APP_HOMES.get(appName)); + // TODO: Refactor the type of APP_HOMES to not require the ?? + router.push(APP_HOMES.get(appName) ?? "/"); } } else if (keyAttributes?.encryptedKey) { router.push(PAGES.CREDENTIALS); @@ -76,7 +78,8 @@ export default function Generate({ appContext, appName }: PageProps) { const { keyAttributes, masterKey, srpSetupAttributes } = await generateKeyAndSRPAttributes(passphrase); - await putAttributes(token, keyAttributes); + // TODO: Refactor the code to not require this ensure + await putAttributes(ensure(token), keyAttributes); await configureSRP(srpSetupAttributes); await generateAndSaveIntermediateKeyAttributes( passphrase, @@ -94,7 +97,7 @@ export default function Generate({ appContext, appName }: PageProps) { return ( <> - {loading ? ( + {loading || !user ? ( @@ -104,7 +107,8 @@ export default function Generate({ appContext, appName }: PageProps) { show={recoverModalView} onHide={() => { setRecoveryModalView(false); - router.push(APP_HOMES.get(appName)); + // TODO: Refactor the type of APP_HOMES to not require the ?? + router.push(APP_HOMES.get(appName) ?? "/"); }} /* TODO: Why is this error being ignored */ somethingWentWrong={() => {}} @@ -114,7 +118,7 @@ export default function Generate({ appContext, appName }: PageProps) { {t("SET_PASSPHRASE")} diff --git a/web/packages/accounts/pages/recover.tsx b/web/packages/accounts/pages/recover.tsx index 2173037d3..09e000487 100644 --- a/web/packages/accounts/pages/recover.tsx +++ b/web/packages/accounts/pages/recover.tsx @@ -53,7 +53,8 @@ export default function Recover({ appContext, appName }: PageProps) { if (!keyAttributes) { router.push(PAGES.GENERATE); } else if (key) { - router.push(APP_HOMES.get(appName)); + // TODO: Refactor the type of APP_HOMES to not require the ?? + router.push(APP_HOMES.get(appName) ?? "/"); } else { setKeyAttributes(keyAttributes); }