feat: 2FAのバックアップコードの実装 (#121)

This commit is contained in:
まっちゃとーにゅ
2023-07-30 03:35:42 +09:00
committed by GitHub
parent 99232ed417
commit 2b941ae648
34 changed files with 91 additions and 32 deletions

View File

@@ -54,8 +54,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
throw new Error('not verified');
}
const backupCodes = Array.from({ length: 20 }, () => {
return new OTPAuth.Secret().base32;
});
await this.userProfilesRepository.update(me.id, {
twoFactorSecret: profile.twoFactorTempSecret,
twoFactorBackupSecret: backupCodes,
twoFactorEnabled: true,
});
@@ -64,6 +69,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
detail: true,
includeSecrets: true,
}));
return {
backupCodes: backupCodes,
};
});
}
}