diff --git a/src/routes/api/recovery_codes.ts b/src/routes/api/recovery_codes.ts index a98e1e38c..78be09966 100644 --- a/src/routes/api/recovery_codes.ts +++ b/src/routes/api/recovery_codes.ts @@ -43,12 +43,10 @@ function getUsedRecoveryCodes() { const dateRegex = RegExp(/^\d{4}\/\d{2}\/\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/gm); const recoveryCodes = recovery_codes.getRecoveryCodes(); - const usedStatus: string[] = []; - recoveryCodes.forEach((recoveryKey: string) => { - if (dateRegex.test(recoveryKey)) usedStatus.push(recoveryKey); - else usedStatus.push(String(recoveryCodes.indexOf(recoveryKey))); - }); + const usedStatus = recoveryCodes.map(recoveryKey => { + return (dateRegex.test(recoveryKey)) ? recoveryKey : String(recoveryCodes.indexOf(recoveryKey)) + }) return { success: true,