From a1f0c1024b2d9dfd16e3f5c41b0e5bf13a12862a Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:59:44 +0530 Subject: [PATCH 1/2] [staff] Fix disable 2FA --- infra/staff/src/components/Disable2FA.tsx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/infra/staff/src/components/Disable2FA.tsx b/infra/staff/src/components/Disable2FA.tsx index c43dbd0992..d26e91093e 100644 --- a/infra/staff/src/components/Disable2FA.tsx +++ b/infra/staff/src/components/Disable2FA.tsx @@ -50,24 +50,33 @@ const Disable2FA: React.FC = ({ const encodedToken = encodeURIComponent(token); // Fetch user data - const userUrl = `${apiOrigin}/admin/user?email=${encodedEmail}&token=${encodedToken}`; - const userResponse = await fetch(userUrl); + const userUrl = `${apiOrigin}/admin/user?email=${encodedEmail}`; + const userResponse = await fetch(userUrl, { + method: "GET", + headers: { + "Content-Type": "application/json", + "X-Auth-Token": encodedToken, + }, + }); if (!userResponse.ok) { throw new Error("Failed to fetch user data"); } const userData = (await userResponse.json()) as UserData; - const userId = userData.subscription?.userID; + const userID = userData.subscription?.userID; - if (!userId) { + if (!userID) { throw new Error("User ID not found"); } // Disable 2FA - const disableUrl = `${apiOrigin}/admin/user/disable-2fa?token=${encodedToken}`; - const body = JSON.stringify({ userId }); + const disableUrl = `${apiOrigin}/admin/user/disable-2fa`; + const body = JSON.stringify({ userID }); const disableResponse = await fetch(disableUrl, { method: "POST", - headers: { "Content-Type": "application/json" }, + headers: { + "Content-Type": "application/json", + "X-Auth-Token": encodedToken, + }, body: body, }); From eb949bcad9b46fc34166f4b79c5e6d87b805ca72 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:07:24 +0530 Subject: [PATCH 2/2] [staff] Lint fix --- infra/staff/src/components/Disable2FA.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/infra/staff/src/components/Disable2FA.tsx b/infra/staff/src/components/Disable2FA.tsx index d26e91093e..b7a14c2de8 100644 --- a/infra/staff/src/components/Disable2FA.tsx +++ b/infra/staff/src/components/Disable2FA.tsx @@ -53,10 +53,10 @@ const Disable2FA: React.FC = ({ const userUrl = `${apiOrigin}/admin/user?email=${encodedEmail}`; const userResponse = await fetch(userUrl, { method: "GET", - headers: { + headers: { "Content-Type": "application/json", "X-Auth-Token": encodedToken, - }, + }, }); if (!userResponse.ok) { throw new Error("Failed to fetch user data"); @@ -73,10 +73,10 @@ const Disable2FA: React.FC = ({ const body = JSON.stringify({ userID }); const disableResponse = await fetch(disableUrl, { method: "POST", - headers: { + headers: { "Content-Type": "application/json", "X-Auth-Token": encodedToken, - }, + }, body: body, });