2段階認証のバックアップコード一覧をテキストファイルでダウンロード可能に (#11957)

This commit is contained in:
CyberRex 2023-10-03 20:27:37 +09:00 committed by GitHub
parent 0f6ee7dc1c
commit a511d8eddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -83,6 +83,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #value><code class="_monospace">{{ code }}</code></template> <template #value><code class="_monospace">{{ code }}</code></template>
</MkKeyValue> </MkKeyValue>
</div> </div>
<MkButton primary rounded gradate @click="downloadBackupCodes"><i class="ti ti-download"></i> {{ i18n.ts.download }}</MkButton>
</div> </div>
</MkFolder> </MkFolder>
</div> </div>
@ -108,6 +110,7 @@ import * as os from '@/os.js';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import { confetti } from '@/scripts/confetti.js'; import { confetti } from '@/scripts/confetti.js';
import { $i } from '@/account.js';
defineProps<{ defineProps<{
twoFactorData: { 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() { function allDone() {
dialog.value.close(); dialog.value.close();
} }