From a511d8eddc6f770def069d7c6a4e8b42dd19e536 Mon Sep 17 00:00:00 2001 From: CyberRex Date: Tue, 3 Oct 2023 20:27:37 +0900 Subject: 2段階認証のバックアップコード一覧をテキストファイルでダウンロード可能に (#11957) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/pages/settings/2fa.qrdialog.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/frontend/src/pages/settings/2fa.qrdialog.vue b/packages/frontend/src/pages/settings/2fa.qrdialog.vue index c2d1694c5b..4641b49103 100644 --- a/packages/frontend/src/pages/settings/2fa.qrdialog.vue +++ b/packages/frontend/src/pages/settings/2fa.qrdialog.vue @@ -83,6 +83,8 @@ SPDX-License-Identifier: AGPL-3.0-only + + {{ i18n.ts.download }} @@ -108,6 +110,7 @@ import * as os from '@/os.js'; import MkFolder from '@/components/MkFolder.vue'; import MkInfo from '@/components/MkInfo.vue'; import { confetti } from '@/scripts/confetti.js'; +import { $i } from '@/account.js'; defineProps<{ twoFactorData: { @@ -143,6 +146,16 @@ async function tokenDone() { }); } +function downloadBackupCodes() { + if (backupCodes.value !== undefined) { + const txtBlob = new Blob([backupCodes.value.join('\n')], { type: 'text/plain' }); + const dummya = document.createElement('a'); + dummya.href = URL.createObjectURL(txtBlob); + dummya.download = `${$i?.username}-2fa-backup-codes.txt`; + dummya.click(); + } +} + function allDone() { dialog.value.close(); } -- cgit v1.2.3-freya