Skip to content

Commit

Permalink
feat: admin can cancel 2fa
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Mar 25, 2023
1 parent aa3349f commit 222b118
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lang/en/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"change_password": "Change Password",
"change_password-tips": "Keep the password empty if you don't want to change it",
"enable_2fa": "Enable 2FA",
"cancel_2fa": "Cancel 2FA",
"cancel_2fa_success": "Cancel 2FA successfully",
"2fa_already_enabled": "2FA is already enabled",
"scan_qr": "Scan the QR code to save the secret key",
"input_code": "Input the code of your 2FA app",
Expand Down
16 changes: 16 additions & 0 deletions src/pages/manage/users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ const Users = () => {
const [deleting, deleteUser] = useListFetch(
(id: number): PEmptyResp => r.post(`/admin/user/delete?id=${id}`)
)
const [cancel_2faId, cancel_2fa] = useListFetch(
(id: number): PEmptyResp => r.post(`/admin/user/cancel_2fa?id=${id}`)
)
return (
<VStack spacing="$2" alignItems="start" w="$full">
<HStack spacing="$2">
Expand Down Expand Up @@ -152,6 +155,19 @@ const Users = () => {
})
}}
/>
<Button
colorScheme="accent"
loading={cancel_2faId() === user.id}
onClick={async () => {
const resp = await cancel_2fa(user.id)
handleResp(resp, () => {
notify.success(t("users.cancel_2fa_success"))
refresh()
})
}}
>
{t("users.cancel_2fa")}
</Button>
</HStack>
</Td>
</Tr>
Expand Down

0 comments on commit 222b118

Please sign in to comment.