Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/frontend/src/pages/settings/2fa.qrdialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #value><code class="_monospace">{{ code }}</code></template>
</MkKeyValue>
</div>

<MkButton primary rounded gradate @click="downloadBackupCodes"><i class="ti ti-download"></i> {{ i18n.ts.download }}</MkButton>
</div>
</MkFolder>
</div>
Expand All @@ -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: {
Expand Down Expand Up @@ -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();
}
Expand Down
Loading