From 8d30bfbefa922c174b548bcedfd3ceaae9d81501 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 25 May 2024 15:43:08 +0530 Subject: [PATCH] tsc --- web/packages/accounts/pages/credentials.tsx | 11 +++++++---- .../shared/components/VerifyMasterPasswordForm.tsx | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/web/packages/accounts/pages/credentials.tsx b/web/packages/accounts/pages/credentials.tsx index 5da52ac02..fee34311f 100644 --- a/web/packages/accounts/pages/credentials.tsx +++ b/web/packages/accounts/pages/credentials.tsx @@ -1,5 +1,6 @@ import { isDevBuild } from "@/next/env"; import log from "@/next/log"; +import { ensure } from "@/utils/ensure"; import { APP_HOMES } from "@ente/shared/apps/constants"; import type { PageProps } from "@ente/shared/apps/types"; import { VerticallyCentered } from "@ente/shared/components/Container"; @@ -194,7 +195,7 @@ export default function Credentials({ appContext, appName }: PageProps) { id, isTwoFactorEnabled: false, }); - setData(LS_KEYS.KEY_ATTRIBUTES, keyAttributes); + setData(LS_KEYS.KEY_ATTRIBUTES, ensure(keyAttributes)); return keyAttributes; } } catch (e) { @@ -225,10 +226,10 @@ export default function Credentials({ appContext, appName }: PageProps) { await saveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, key); await decryptAndStoreToken(keyAttributes, key); try { - let srpAttributes: SRPAttributes = getData( + let srpAttributes: SRPAttributes | null = getData( LS_KEYS.SRP_ATTRIBUTES, ); - if (!srpAttributes) { + if (!srpAttributes && user) { srpAttributes = await getSRPAttributes(user.email); if (srpAttributes) { setData(LS_KEYS.SRP_ATTRIBUTES, srpAttributes); @@ -262,10 +263,12 @@ export default function Credentials({ appContext, appName }: PageProps) { ); } + // TODO: Handle the case when user is not present, or exclude that + // possibility using types. return ( -
{user.email}
+
{user?.email ?? ""}