Skip to content

armgit / ente

Public Imported from GitHub
0

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

del api

Manav Rathicba85799f0ef
diff --git a/web/apps/photos/src/components/DeleteAccount.tsx b/web/apps/photos/src/components/DeleteAccount.tsx
index 19cf20f0cd..d3ff921b9c 100644
--- a/web/apps/photos/src/components/DeleteAccount.tsx
+++ b/web/apps/photos/src/components/DeleteAccount.tsx
@@ -7,7 +7,10 @@ import {
DropdownInput,
type DropdownOption,
} from "@/new/photos/components/DropdownInput";
-import { getAccountDeleteChallenge } from "@/new/photos/services/user";
+import {
+ deleteAccount,
+ getAccountDeleteChallenge,
+} from "@/new/photos/services/user";
import { initiateEmail } from "@/new/photos/utils/web";
import { decryptDeleteAccountChallenge } from "@ente/shared/crypto/helpers";
import {
@@ -23,7 +26,6 @@ import { useFormik } from "formik";
import { t } from "i18next";
import React, { useState } from "react";
import { Trans } from "react-i18next";
-import { deleteAccount } from "services/userService";
type DeleteAccountProps = ModalVisibilityProps & {
/**
diff --git a/web/apps/photos/src/services/userService.ts b/web/apps/photos/src/services/userService.ts
index ba089377bf..64a9a0c8d8 100644
--- a/web/apps/photos/src/services/userService.ts
+++ b/web/apps/photos/src/services/userService.ts
@@ -80,28 +80,3 @@ export const getUserDetailsV2 = async (): Promise<UserDetails> => {
throw e;
}
};
-
-export const deleteAccount = async (
- challenge: string,
- reason: string,
- feedback: string,
-) => {
- try {
- const token = getToken();
- if (!token) {
- return;
- }
-
- await HTTPService.delete(
- await apiURL("/users/delete"),
- { challenge, reason, feedback },
- null,
- {
- "X-Auth-Token": token,
- },
- );
- } catch (e) {
- log.error("deleteAccount api call failed", e);
- throw e;
- }
-};
diff --git a/web/packages/new/photos/services/user.ts b/web/packages/new/photos/services/user.ts
index 5858a037a8..7ddacbd12a 100644
--- a/web/packages/new/photos/services/user.ts
+++ b/web/packages/new/photos/services/user.ts
@@ -41,3 +41,23 @@ export const getAccountDeleteChallenge = async () => {
ensureOk(res);
return DeleteChallengeResponse.parse(await res.json());
};
+
+/**
+ * Delete the logged in user's account on remote.
+ *
+ * @param challenge Decrypted value of the challenge previously obtained via
+ * {@link getAccountDeleteChallenge}. The decryption algorithm is implemented in
+ * {@link decryptDeleteAccountChallenge}.
+ */
+export const deleteAccount = async (
+ challenge: string,
+ reason: string,
+ feedback: string,
+) =>
+ ensureOk(
+ await fetch(await apiURL("/users/delete"), {
+ method: "DELETE",
+ headers: await authenticatedRequestHeaders(),
+ body: JSON.stringify({ challenge, reason, feedback }),
+ }),
+ );