Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTara Rostami <132676256+TaraRostami@users.noreply.github.com>2025-05-11 03:12:43 +0300
committerGitHub <noreply@github.com>2025-05-11 03:12:43 +0300
commit58f978bb0a26887d87b8098df8080280171aa05a (patch)
tree12c0cac89a8247dade5f918ec202d5980e1277c7 /web/html/modals
parent6d4749606961b665de8bd7ad4246864ce3915256 (diff)
fix: 2fa qr-code (#2996)
Diffstat (limited to 'web/html/modals')
-rw-r--r--web/html/modals/two_factor_modal.html49
1 files changed, 32 insertions, 17 deletions
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 @@
<a-divider></a-divider>
<p>{{ i18n "pages.settings.security.twoFactorModalFirstStep" }}</p>
<div :style="{ display: 'flex', alignItems: 'center', flexDirection: 'column', gap: '12px' }">
- <div
- :style="{ border: '1px solid', borderRadius: '1rem', borderColor: themeSwitcher.isDarkTheme ? 'var(--dark-color-surface-300)' : '#d9d9d9', padding: 0 }">
- <img :src="twoFactorModal.qrImage"
- :style="{ filter: themeSwitcher.isDarkTheme ? 'invert(1)' : 'none'}"
- :alt="twoFactorModal.token">
+ <div class="qr-bg" :style="{ width: '180px', height: '180px' }">
+ <canvas @click="copy(twoFactorModal.token)" id="twofactor-qrcode" class="qr-cv"></canvas>
</div>
<span :style="{ fontSize: '12px', fontFamily: 'monospace' }">[[ twoFactorModal.token ]]</span>
</div>
@@ -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" }}')
+ })
+ },
+ }
});
</script>
{{end}} \ No newline at end of file