π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move
Manav Rathi611239647934
diff --git a/web/apps/photos/src/components/Sidebar/TwoFactorSettings.tsx b/web/apps/photos/src/components/Sidebar/TwoFactorSettings.tsxindex 7b797d4a8a..9b8c5543b5 100644--- a/web/apps/photos/src/components/Sidebar/TwoFactorSettings.tsx+++ b/web/apps/photos/src/components/Sidebar/TwoFactorSettings.tsx@@ -5,7 +5,7 @@ import {SidebarDrawerTitlebar,type NestedSidebarDrawerVisibilityProps,} from "@/base/components/mui/SidebarDrawer";-import { disable2FA } from "@/new/photos/services/user";+import { disable2FA, get2FAStatus } from "@/new/photos/services/user";import { useAppContext } from "@/new/photos/types/context";import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";@@ -15,7 +15,6 @@ import { Stack, Typography } from "@mui/material";import { t } from "i18next";import router, { useRouter } from "next/router";import { useEffect, useState } from "react";-import { getTwoFactorStatus } from "services/userService";export const TwoFactorSettings: React.FC<NestedSidebarDrawerVisibilityProps@@ -33,11 +32,11 @@ export const TwoFactorSettings: React.FC<return;}const main = async () => {- const isTwoFactorEnabled = await getTwoFactorStatus();- setIsTwoFactorEnabled(isTwoFactorEnabled);+ const isEnabled = await get2FAStatus();+ setIsTwoFactorEnabled(isEnabled);await setLSUser({...getData(LS_KEYS.USER),- isTwoFactorEnabled,+ isTwoFactorEnabled: isEnabled,});};main();diff --git a/web/apps/photos/src/services/userService.ts b/web/apps/photos/src/services/userService.tsindex 133c560584..4dcda53234 100644--- a/web/apps/photos/src/services/userService.ts+++ b/web/apps/photos/src/services/userService.ts@@ -103,17 +103,6 @@ export const isTokenValid = async (token: string) => {}};-export const getTwoFactorStatus = async () => {- const resp = await HTTPService.get(- await apiURL("/users/two-factor/status"),- null,- {- "X-Auth-Token": getToken(),- },- );- return resp.data["status"];-};-export const getUserDetailsV2 = async (): Promise<UserDetails> => {try {const token = getToken();diff --git a/web/packages/new/photos/services/user.ts b/web/packages/new/photos/services/user.tsindex 74e4b24161..58bd087e74 100644--- a/web/packages/new/photos/services/user.ts+++ b/web/packages/new/photos/services/user.ts@@ -1,5 +1,6 @@import { authenticatedRequestHeaders, ensureOk } from "@/base/http";import { apiURL } from "@/base/origins";+import { z } from "zod";export interface FamilyMember {email: string;@@ -14,6 +15,17 @@ export interface FamilyData {members: FamilyMember[];}+/**+ * Fetch the two-factor status (whether or not it is enabled) from remote.+ */+export const get2FAStatus = async () => {+ const res = await fetch(await apiURL("/users/two-factor/status"), {+ headers: await authenticatedRequestHeaders(),+ });+ ensureOk(res);+ return z.object({ status: z.boolean() }).parse(await res.json()).status;+};+/*** Disable two-factor authentication for the current user on remote.*/