refactor(routes/api/recovery_codes): use Array.from with mapFn in generateRecoveryCodes

gives us the identical result as before, but a lot more concise and "DRY"
This commit is contained in:
Panagiotis Papadopoulos
2025-04-09 09:43:38 +02:00
parent 80dd925231
commit da649d75c0

View File

@@ -20,16 +20,7 @@ function checkForRecoveryKeys() {
}
function generateRecoveryCodes() {
const recoveryKeys = [
randomBytes(16).toString('base64'),
randomBytes(16).toString('base64'),
randomBytes(16).toString('base64'),
randomBytes(16).toString('base64'),
randomBytes(16).toString('base64'),
randomBytes(16).toString('base64'),
randomBytes(16).toString('base64'),
randomBytes(16).toString('base64')
];
const recoveryKeys = Array.from({ length: 8 }, () => randomBytes(16).toString('base64'));
recovery_codes.setRecoveryCodes(recoveryKeys.join(','));