Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update

Manav Rathi70f40aa10375
diff --git a/web/apps/photos/src/components/Sidebar/TwoFactorSettings.tsx b/web/apps/photos/src/components/Sidebar/TwoFactorSettings.tsx
index 41d9703a32..7b797d4a8a 100644
--- a/web/apps/photos/src/components/Sidebar/TwoFactorSettings.tsx
+++ b/web/apps/photos/src/components/Sidebar/TwoFactorSettings.tsx
@@ -1,4 +1,3 @@
-import { disableTwoFactor } from "@/accounts/api/user";
import { MenuItemGroup, MenuSectionTitle } from "@/base/components/Menu";
import { FocusVisibleButton } from "@/base/components/mui/FocusVisibleButton";
import {
@@ -6,6 +5,7 @@ import {
SidebarDrawerTitlebar,
type NestedSidebarDrawerVisibilityProps,
} from "@/base/components/mui/SidebarDrawer";
+import { disable2FA } 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";
@@ -118,7 +118,7 @@ const ManageDrawerContents: React.FC<ContentsProps> = ({ onRootClose }) => {
});
const disable = async () => {
- await disableTwoFactor();
+ await disable2FA();
await setLSUser({
...getData(LS_KEYS.USER),
isTwoFactorEnabled: false,
diff --git a/web/packages/accounts/api/user.ts b/web/packages/accounts/api/user.ts
index 667eaf10c9..763dbb190a 100644
--- a/web/packages/accounts/api/user.ts
+++ b/web/packages/accounts/api/user.ts
@@ -176,14 +176,3 @@ export const setRecoveryKey = async (token: string, recoveryKey: RecoveryKey) =>
"X-Auth-Token": token,
},
);
-
-export const disableTwoFactor = async () => {
- await HTTPService.post(
- await apiURL("/users/two-factor/disable"),
- null,
- undefined,
- {
- "X-Auth-Token": getToken(),
- },
- );
-};
diff --git a/web/packages/new/photos/services/user.ts b/web/packages/new/photos/services/user.ts
index 6e7b08611e..74e4b24161 100644
--- a/web/packages/new/photos/services/user.ts
+++ b/web/packages/new/photos/services/user.ts
@@ -1,3 +1,6 @@
+import { authenticatedRequestHeaders, ensureOk } from "@/base/http";
+import { apiURL } from "@/base/origins";
+
export interface FamilyMember {
email: string;
usage: number;
@@ -10,3 +13,14 @@ export interface FamilyData {
expiry: number;
members: FamilyMember[];
}
+
+/**
+ * Disable two-factor authentication for the current user on remote.
+ */
+export const disable2FA = async () =>
+ ensureOk(
+ await fetch(await apiURL("/users/two-factor/disable"), {
+ method: "POST",
+ headers: await authenticatedRequestHeaders(),
+ }),
+ );