1
0
Fork 0

[react] feat: Admin button to disable MFA

This commit is contained in:
joostdecock 2025-04-27 16:45:19 +02:00
parent a97bb4e803
commit c44c77bd2a

View file

@ -197,6 +197,20 @@ export const User = ({ user, Link }) => {
} else setLoadingStatus([true, 'An error occured', true, false]) } else setLoadingStatus([true, 'An error occured', true, false])
} }
/*
* Disable MFA for users who locked themselves out
*/
const disableMfa = async () => {
setLoadingStatus([true, 'Contacting backend'])
const [status, body] = await backend.adminUpdateUser({
id: user.id,
data: { mfaEnabled: false },
})
if (status === 200 && body.result === 'success') {
setLoadingStatus([true, 'MFA disabled', true, true])
} else setLoadingStatus([true, 'An error occured', true, false])
}
return ( return (
<div className="tw:flex tw:flex-row tw:w-full tw:gap-4 tw:my-2"> <div className="tw:flex tw:flex-row tw:w-full tw:gap-4 tw:my-2">
<button <button
@ -237,6 +251,15 @@ export const User = ({ user, Link }) => {
Details Details
</button> </button>
<ImpersonateButton userId={user.id} /> <ImpersonateButton userId={user.id} />
{user.mfaEnabled ? (
<button
className="tw:daisy-btn tw:daisy-btn-warning tw:daisy-btn-sm"
onClick={disableMfa}
>
Disable MFA
</button>
) : null}
{user.consent < 1 ? ( {user.consent < 1 ? (
<button <button
className="tw:daisy-btn tw:daisy-btn-warning tw:daisy-btn-sm" className="tw:daisy-btn tw:daisy-btn-warning tw:daisy-btn-sm"