This commit is contained in:
Manav Rathi 2024-11-05 10:16:08 +05:30
parent 73ea3d167d
commit 70f40aa103
No known key found for this signature in database
3 changed files with 16 additions and 13 deletions

View File

@ -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,

View File

@ -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(),
},
);
};

View File

@ -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(),
}),
);