From ad17358fb3da3dd55f3f74c32ed06a2cd3bac1f1 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Tue, 3 Oct 2023 17:28:18 -0400 Subject: [PATCH] Give user better feedback when en/disabling totp --- src/shared/components/person/settings.tsx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx index 35631b99..e0332a9c 100644 --- a/src/shared/components/person/settings.tsx +++ b/src/shared/components/person/settings.tsx @@ -1074,15 +1074,31 @@ export class Settings extends Component { totp_token: totp, }); - console.log("updating 2fa"); - if (updateTotpRes.state === "failed") { toast("Invalid TOTP", "danger"); } this.setState({ updateTotpRes }); - return updateTotpRes.state === "success"; + const succeeded = updateTotpRes.state === "success"; + if (succeeded) { + const siteRes = await HttpService.client.getSite(); + UserService.Instance.myUserInfo!.local_user_view.local_user.totp_2fa_enabled = + enabled; + + if (siteRes.state === "success") { + this.setState({ siteRes: siteRes.data }); + } + + toast( + `Successfully ${ + enabled ? "enabled" : "disabled" + } 2 factor authentication`, + "success", + ); + } + + return succeeded; } handleEnable2fa(totp: string) {