π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Conv
Manav Rathib8f8d90d13bc
diff --git a/web/packages/accounts/components/LoginContents.tsx b/web/packages/accounts/components/LoginContents.tsxindex 968ebf81af..24741b5d0b 100644--- a/web/packages/accounts/components/LoginContents.tsx+++ b/web/packages/accounts/components/LoginContents.tsx@@ -1,12 +1,14 @@import { Input, Stack, TextField, Typography } from "@mui/material";import { AccountsPageFooter } from "ente-accounts/components/layouts/centered-paper";-import { getSRPAttributes } from "ente-accounts/services/srp";-import { sendOTT } from "ente-accounts/services/user";+import {+ getSRPAttributes,+ saveSRPAttributes,+} from "ente-accounts/services/srp";+import { savePartialLocalUser, sendOTT } from "ente-accounts/services/user";import { LinkButton } from "ente-base/components/LinkButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { isMuseumHTTPError } from "ente-base/http";import log from "ente-base/log";-import { setData, setLSUser } from "ente-shared/storage/localStorage";import { useFormik } from "formik";import { t } from "i18next";import { useRouter } from "next/router";@@ -35,7 +37,6 @@ export const LoginContents: React.FC<LoginContentsProps> = ({const loginUser = useCallback(async (email: string, setFieldError: (message: string) => void) => {const srpAttributes = await getSRPAttributes(email);- log.debug(() => ["srpAttributes", JSON.stringify(srpAttributes)]);if (!srpAttributes || srpAttributes.isEmailMFAEnabled) {try {await sendOTT(email, "login");@@ -48,11 +49,11 @@ export const LoginContents: React.FC<LoginContentsProps> = ({}throw e;}- await setLSUser({ email });+ savePartialLocalUser({ email });void router.push("/verify");} else {- await setLSUser({ email });- setData("srpAttributes", srpAttributes);+ savePartialLocalUser({ email });+ saveSRPAttributes(srpAttributes);void router.push("/credentials");}},diff --git a/web/packages/accounts/services/user.ts b/web/packages/accounts/services/user.tsindex a141bf6ed8..a573cf5c72 100644--- a/web/packages/accounts/services/user.ts+++ b/web/packages/accounts/services/user.ts@@ -100,6 +100,18 @@ export const partialLocalUser = (): Partial<LocalUser> | undefined => {return LocalUser.partial().parse(JSON.parse(s));};+/**+ * Save the users data as we accrue it during the signup or login flow.+ *+ * See: [Note: Partial local user].+ *+ * TODO: WARNING: This does not update the KV token. The idea is to gradually+ * move over uses of setLSUser to this while explicitly setting the KV token+ * where needed.+ */+export const savePartialLocalUser = (partialLocalUser: Partial<LocalUser>) =>+ localStorage.setItem("user", JSON.stringify(partialLocalUser));+/*** Return the logged-in user, if someone is indeed logged in. Otherwise return* `undefined`.