From 0037e05bce9b8371fcac44a88d5d1ded321a52a8 Mon Sep 17 00:00:00 2001 From: Bailetti Tommaso Date: Thu, 7 Nov 2024 12:14:13 +0100 Subject: [PATCH] feat(controller): added 2fa auth (#426) --- .../controller/ControllerAppLogin.vue | 201 +++++++++++------- .../controller/users/UsersTable.vue | 17 ++ .../standalone/StandaloneAppLogin.vue | 2 +- .../account/two_fa/TwoFactorAuth.vue | 6 +- .../two_fa/ConfigureTwoFaDrawer.vue | 8 +- .../account => }/two_fa/RevokeTwoFaModal.vue | 12 +- src/i18n/en/translation.json | 5 +- src/lib/standalone/twoFa.ts | 70 ------ src/lib/twoFa.ts | 74 +++++++ src/stores/controller/accounts.ts | 1 + src/stores/controller/controllerLogin.ts | 54 +++-- src/views/controller/AccountView.vue | 11 + src/views/controller/UsersView.vue | 8 +- 13 files changed, 290 insertions(+), 179 deletions(-) rename src/components/{standalone/account => }/two_fa/ConfigureTwoFaDrawer.vue (93%) rename src/components/{standalone/account => }/two_fa/RevokeTwoFaModal.vue (91%) delete mode 100644 src/lib/standalone/twoFa.ts create mode 100644 src/lib/twoFa.ts diff --git a/src/components/controller/ControllerAppLogin.vue b/src/components/controller/ControllerAppLogin.vue index 1e39f30b0..7ff4f790f 100644 --- a/src/components/controller/ControllerAppLogin.vue +++ b/src/components/controller/ControllerAppLogin.vue @@ -5,34 +5,36 @@ @@ -148,29 +159,59 @@ function validate() { {{ t('login.privacy_policy') }} -
+ + + + {{ t('standalone.two_fa.verify_code') }} + + +
@@ -200,6 +241,8 @@ function validate() { kind="primary" size="lg" @click.prevent="login" + :disabled="loading" + :loading="loading" type="submit" class="w-full" >{{ t('login.sign_in') }} {{ t('controller.users.display_name') }} + + {{ t('controller.users.two_fa_status') }} + @@ -75,6 +80,18 @@ function getDropdownItems(item: ControllerAccount) { {{ item.display_name }} + + + + + +
diff --git a/src/components/standalone/StandaloneAppLogin.vue b/src/components/standalone/StandaloneAppLogin.vue index a719df768..f719377ed 100644 --- a/src/components/standalone/StandaloneAppLogin.vue +++ b/src/components/standalone/StandaloneAppLogin.vue @@ -22,7 +22,7 @@ import { MessageBag, validateRequired, validateSixDigitCode } from '@/lib/valida import { useI18n } from 'vue-i18n' import { getProductName, getCompanyName, getPrivacyPolicyUrl } from '@/lib/config' import { jwtDecode } from 'jwt-decode' -import { verifyTwoFaOtp } from '@/lib/standalone/twoFa' +import { verifyTwoFaOtp } from '@/lib/twoFa' import { ValidationError } from '@/lib/standalone/ubus' let username = ref('') diff --git a/src/components/standalone/account/two_fa/TwoFactorAuth.vue b/src/components/standalone/account/two_fa/TwoFactorAuth.vue index 759e373b9..f12d58414 100644 --- a/src/components/standalone/account/two_fa/TwoFactorAuth.vue +++ b/src/components/standalone/account/two_fa/TwoFactorAuth.vue @@ -6,7 +6,7 @@