Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

tsc

Manav Rathi8d30bfbefa92
diff --git a/web/packages/accounts/pages/credentials.tsx b/web/packages/accounts/pages/credentials.tsx
index 5da52ac023..fee34311fd 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 (
<VerticallyCentered>
<FormPaper style={{ minWidth: "320px" }}>
- <Header>{user.email}</Header>
+ <Header>{user?.email ?? ""}</Header>
<VerifyMasterPasswordForm
buttonText={t("VERIFY_PASSPHRASE")}
diff --git a/web/packages/shared/components/VerifyMasterPasswordForm.tsx b/web/packages/shared/components/VerifyMasterPasswordForm.tsx
index 9e39ba252b..c84761d3f2 100644
--- a/web/packages/shared/components/VerifyMasterPasswordForm.tsx
+++ b/web/packages/shared/components/VerifyMasterPasswordForm.tsx
@@ -10,7 +10,7 @@ import { CustomError } from "../error";
import type { KeyAttributes, User } from "../user/types";
export interface VerifyMasterPasswordFormProps {
- user: User;
+ user: User | undefined;
keyAttributes: KeyAttributes | undefined;
callback: (
key: string,