mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 15:30:40 +00:00
[staff] Surface error as dialog
This commit is contained in:
parent
eb949bcad9
commit
f2210fbbae
@ -47,7 +47,6 @@ const Disable2FA: React.FC<Disable2FAProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const encodedEmail = encodeURIComponent(email);
|
const encodedEmail = encodeURIComponent(email);
|
||||||
const encodedToken = encodeURIComponent(token);
|
|
||||||
|
|
||||||
// Fetch user data
|
// Fetch user data
|
||||||
const userUrl = `${apiOrigin}/admin/user?email=${encodedEmail}`;
|
const userUrl = `${apiOrigin}/admin/user?email=${encodedEmail}`;
|
||||||
@ -55,7 +54,7 @@ const Disable2FA: React.FC<Disable2FAProps> = ({
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Auth-Token": encodedToken,
|
"X-Auth-Token": token,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!userResponse.ok) {
|
if (!userResponse.ok) {
|
||||||
@ -75,7 +74,7 @@ const Disable2FA: React.FC<Disable2FAProps> = ({
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Auth-Token": encodedToken,
|
"X-Auth-Token": token,
|
||||||
},
|
},
|
||||||
body: body,
|
body: body,
|
||||||
});
|
});
|
||||||
@ -84,12 +83,15 @@ const Disable2FA: React.FC<Disable2FAProps> = ({
|
|||||||
const errorResponse = await disableResponse.text();
|
const errorResponse = await disableResponse.text();
|
||||||
throw new Error(`Failed to disable 2FA: ${errorResponse}`);
|
throw new Error(`Failed to disable 2FA: ${errorResponse}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDisable2FA(); // Notify parent component of successful disable
|
handleDisable2FA(); // Notify parent component of successful disable
|
||||||
handleClose(); // Close dialog on successful disable
|
handleClose(); // Close dialog on successful disable
|
||||||
console.log("2FA disabled successfully");
|
console.log("2FA disabled successfully");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error disabling 2FA:", error);
|
if (error instanceof Error) {
|
||||||
|
alert(error.message);
|
||||||
|
} else {
|
||||||
|
alert("Failed to disable 2FA");
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user