Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[staff] Fix disable 2FA #4032

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions infra/staff/src/components/Disable2FA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,33 @@ const Disable2FA: React.FC<Disable2FAProps> = ({
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,
});

Expand Down
Loading