From 58f978bb0a26887d87b8098df8080280171aa05a Mon Sep 17 00:00:00 2001 From: Tara Rostami <132676256+TaraRostami@users.noreply.github.com> Date: Sat, 10 May 2025 19:12:43 -0500 Subject: fix: 2fa qr-code (#2996) --- web/html/modals/two_factor_modal.html | 49 +++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'web/html/modals/two_factor_modal.html') diff --git a/web/html/modals/two_factor_modal.html b/web/html/modals/two_factor_modal.html index d2f8c442..7823485f 100644 --- a/web/html/modals/two_factor_modal.html +++ b/web/html/modals/two_factor_modal.html @@ -6,11 +6,8 @@

{{ i18n "pages.settings.security.twoFactorModalFirstStep" }}

-
- +
+
[[ twoFactorModal.token ]]
@@ -88,18 +85,6 @@ period: 30, secret: twoFactorModal.token, }); - - if (type === 'set') { - this.qrImage = new QRious({ - size: 150, - value: twoFactorModal.totpObject.toString(), - background: 'white', - backgroundAlpha: 0, - foreground: 'black', - padding: 12, - level: 'L' - }).toDataURL() - } }, close: function () { twoFactorModal.enteredCode = ""; @@ -113,6 +98,36 @@ data: { twoFactorModal: twoFactorModal, }, + updated() { + if ( + this.twoFactorModal.visible && + this.twoFactorModal.type === 'set' && + document.getElementById('twofactor-qrcode') + ) { + this.setQrCode('twofactor-qrcode', this.twoFactorModal.totpObject.toString()); + } + }, + methods: { + setQrCode(elementId, content) { + new QRious({ + element: document.getElementById(elementId), + size: 200, + value: content, + background: 'white', + backgroundAlpha: 0, + foreground: 'black', + padding: 2, + level: 'L' + }); + }, + copy(content) { + ClipboardManager + .copyText(content) + .then(() => { + app.$message.success('{{ i18n "copied" }}') + }) + }, + } }); {{end}} \ No newline at end of file -- cgit v1.2.3