From fe3b1c9b52f584b0f045907585b206344fed55db Mon Sep 17 00:00:00 2001 From: "Shishkevich D." <135337715+shishkevichd@users.noreply.github.com> Date: Thu, 8 May 2025 21:20:58 +0700 Subject: chore: implement 2fa auth (#2968) * chore: implement 2fa auth from #2786 * chore: format code * chore: replace two factor token input with qr-code * chore: requesting confirmation of setting/removing two-factor authentication otpauth library was taken from cdnjs * chore: revert changes in `ClipboardManager` don't need it. * chore: removing twoFactor prop in settings page * chore: remove `twoFactorQr` object in `mounted` function --- web/html/login.html | 20 +++--- web/html/modals/two_factor_modal.html | 118 ++++++++++++++++++++++++++++++++++ web/html/settings.html | 64 +++++++++--------- web/html/settings/panel/security.html | 24 ++----- 4 files changed, 163 insertions(+), 63 deletions(-) create mode 100644 web/html/modals/two_factor_modal.html (limited to 'web/html') diff --git a/web/html/login.html b/web/html/login.html index 9f292d84..515ea2b3 100644 --- a/web/html/login.html +++ b/web/html/login.html @@ -512,11 +512,11 @@ - - + + - + @@ -549,14 +549,14 @@ user: { username: "", password: "", - loginSecret: "" + twoFactorCode: "" }, - secretEnable: false, + twoFactorEnable: false, lang: "" }, async mounted() { this.lang = LanguageManager.getLanguage(); - this.secretEnable = await this.getSecretStatus(); + this.twoFactorEnable = await this.getTwoFactorEnable(); }, methods: { async login() { @@ -567,12 +567,12 @@ location.href = basePath + 'panel/'; } }, - async getSecretStatus() { + async getTwoFactorEnable() { this.loading = true; - const msg = await HttpUtil.post('/getSecretStatus'); + const msg = await HttpUtil.post('/getTwoFactorEnable'); this.loading = false; if (msg.success) { - this.secretEnable = msg.obj; + this.twoFactorEnable = msg.obj; return msg.obj; } }, diff --git a/web/html/modals/two_factor_modal.html b/web/html/modals/two_factor_modal.html new file mode 100644 index 00000000..d2f8c442 --- /dev/null +++ b/web/html/modals/two_factor_modal.html @@ -0,0 +1,118 @@ +{{define "modals/twoFactorModal"}} + + + {{ i18n "pages.settings.security.twoFactorModalSteps" }} + + {{ i18n "pages.settings.security.twoFactorModalFirstStep" }} + + + + + [[ twoFactorModal.token ]] + + + {{ i18n "pages.settings.security.twoFactorModalSecondStep" }} + + + + {{ i18n "pages.settings.security.twoFactorModalRemoveStep" }} + + + + + {{ i18n "cancel" }} + + + {{ i18n "confirm" }} + + + + + +{{end}} \ No newline at end of file diff --git a/web/html/settings.html b/web/html/settings.html index 82e636d9..dec40de7 100644 --- a/web/html/settings.html +++ b/web/html/settings.html @@ -122,10 +122,13 @@ {{template "js" .}} + + {{template "component/aSidebar" .}} {{template "component/aThemeSwitch" .}} {{template "component/aSettingListItem" .}} +{{template "modals/twoFactorModal"}}
{{ i18n "pages.settings.security.twoFactorModalSteps" }}
{{ i18n "pages.settings.security.twoFactorModalFirstStep" }}
{{ i18n "pages.settings.security.twoFactorModalSecondStep" }}
{{ i18n "pages.settings.security.twoFactorModalRemoveStep" }}