mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
2
This commit is contained in:
parent
4acd17f06b
commit
22fbf0a1be
@ -3,7 +3,7 @@ import { useContext } from "react";
|
||||
|
||||
import { disableTwoFactor } from "@ente/accounts/api/user";
|
||||
import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
|
||||
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
|
||||
import { LS_KEYS, getData, setLSUser } from "@ente/shared/storage/localStorage";
|
||||
import { Button, Grid } from "@mui/material";
|
||||
import router from "next/router";
|
||||
import { AppContext } from "pages/_app";
|
||||
@ -33,7 +33,7 @@ export default function TwoFactorModalManageSection(props: Iprops) {
|
||||
const twoFactorDisable = async () => {
|
||||
try {
|
||||
await disableTwoFactor();
|
||||
setData(LS_KEYS.USER, {
|
||||
await setLSUser({
|
||||
...getData(LS_KEYS.USER),
|
||||
isTwoFactorEnabled: false,
|
||||
});
|
||||
|
@ -5,7 +5,7 @@ import LinkButton from "@ente/shared/components/LinkButton";
|
||||
import SingleInputForm, {
|
||||
type SingleInputFormProps,
|
||||
} from "@ente/shared/components/SingleInputForm";
|
||||
import { LS_KEYS, setData } from "@ente/shared/storage/localStorage";
|
||||
import { LS_KEYS, setData, setLSUser } from "@ente/shared/storage/localStorage";
|
||||
import { Input, Stack, Typography } from "@mui/material";
|
||||
import { t } from "i18next";
|
||||
import { useRouter } from "next/router";
|
||||
@ -27,7 +27,7 @@ export const Login: React.FC<LoginProps> = ({ signUp, host }) => {
|
||||
setFieldError,
|
||||
) => {
|
||||
try {
|
||||
setData(LS_KEYS.USER, { email });
|
||||
await setLSUser({ email });
|
||||
const srpAttributes = await getSRPAttributes(email);
|
||||
log.debug(() => ` srpAttributes: ${JSON.stringify(srpAttributes)}`);
|
||||
if (!srpAttributes || srpAttributes.isEmailMFAEnabled) {
|
||||
|
@ -4,7 +4,7 @@ import { PasswordStrengthHint } from "@ente/accounts/components/PasswordStrength
|
||||
import { PAGES } from "@ente/accounts/constants/pages";
|
||||
import { isWeakPassword } from "@ente/accounts/utils";
|
||||
import { generateKeyAndSRPAttributes } from "@ente/accounts/utils/srp";
|
||||
import { LS_KEYS } from "@ente/shared//storage/localStorage";
|
||||
import { LS_KEYS, setLSUser } from "@ente/shared//storage/localStorage";
|
||||
import { VerticallyCentered } from "@ente/shared/components/Container";
|
||||
import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
|
||||
import FormPaperTitle from "@ente/shared/components/Form/FormPaper/Title";
|
||||
@ -82,7 +82,7 @@ export const SignUp: React.FC<SignUpProps> = ({ router, login, host }) => {
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
setData(LS_KEYS.USER, { email });
|
||||
await setLSUser({ email });
|
||||
setLocalReferralSource(referral);
|
||||
await sendOtt(email);
|
||||
} catch (e) {
|
||||
|
@ -8,7 +8,7 @@ import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
|
||||
import FormPaperTitle from "@ente/shared/components/Form/FormPaper/Title";
|
||||
import LinkButton from "@ente/shared/components/LinkButton";
|
||||
import SubmitButton from "@ente/shared/components/SubmitButton";
|
||||
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
|
||||
import { LS_KEYS, getData, setData, setLSUser } from "@ente/shared/storage/localStorage";
|
||||
import { Alert, Box, TextField } from "@mui/material";
|
||||
import { Formik, type FormikHelpers } from "formik";
|
||||
import { t } from "i18next";
|
||||
@ -83,7 +83,7 @@ const ChangeEmailForm: React.FC = () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
await changeEmail(email, ensure(ott));
|
||||
setData(LS_KEYS.USER, { ...getData(LS_KEYS.USER), email });
|
||||
await setLSUser({ ...getData(LS_KEYS.USER), email });
|
||||
setLoading(false);
|
||||
setSuccess(true);
|
||||
await wait(1000);
|
||||
|
@ -28,6 +28,7 @@ import {
|
||||
clearData,
|
||||
getData,
|
||||
setData,
|
||||
setLSUser,
|
||||
} from "@ente/shared/storage/localStorage";
|
||||
import {
|
||||
getToken,
|
||||
@ -224,7 +225,7 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
|
||||
sessionKeyAttributes,
|
||||
);
|
||||
const user = getData(LS_KEYS.USER);
|
||||
setData(LS_KEYS.USER, {
|
||||
await setLSUser({
|
||||
...user,
|
||||
passkeySessionID,
|
||||
isTwoFactorEnabled: true,
|
||||
@ -244,7 +245,7 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
|
||||
sessionKeyAttributes,
|
||||
);
|
||||
const user = getData(LS_KEYS.USER);
|
||||
setData(LS_KEYS.USER, {
|
||||
await setLSUser({
|
||||
...user,
|
||||
twoFactorSessionID,
|
||||
isTwoFactorEnabled: true,
|
||||
@ -253,7 +254,7 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
|
||||
throw Error(CustomError.TWO_FACTOR_ENABLED);
|
||||
} else {
|
||||
const user = getData(LS_KEYS.USER);
|
||||
setData(LS_KEYS.USER, {
|
||||
await setLSUser({
|
||||
...user,
|
||||
token,
|
||||
encryptedToken,
|
||||
|
@ -53,10 +53,10 @@ export const clearData = () => localStorage.clear();
|
||||
// accessed from web workers to KV DB.
|
||||
//
|
||||
// Creating a new function here to act as a funnel point.
|
||||
export const setLSUser = (user: object) => {
|
||||
export const setLSUser = async (user: object) => {
|
||||
const token = user["token"];
|
||||
token && typeof token == "string"
|
||||
? setKV("token", token)
|
||||
: removeKV("token");
|
||||
? await setKV("token", token)
|
||||
: await removeKV("token");
|
||||
setData(LS_KEYS.USER, user);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user