mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-01 04:12:58 +08:00
types(recovery_codes): use sql.transactional Generics to simplify typings
This commit is contained in:
parent
af85ef0b47
commit
eae68064e5
@ -27,7 +27,7 @@ function getRecoveryCodes() {
|
||||
return []
|
||||
}
|
||||
|
||||
return sql.transactional(() => {
|
||||
return sql.transactional<string[]>(() => {
|
||||
const iv = Buffer.from(optionService.getOption('recoveryCodeInitialVector'), 'hex');
|
||||
const securityKey = Buffer.from(optionService.getOption('recoveryCodeSecurityKey'), 'hex');
|
||||
const encryptedRecoveryCodes = optionService.getOption('recoveryCodesEncrypted');
|
||||
@ -41,7 +41,7 @@ function getRecoveryCodes() {
|
||||
}
|
||||
|
||||
function removeRecoveryCode(usedCode: string) {
|
||||
const oldCodes: string[] = getRecoveryCodes();
|
||||
const oldCodes = getRecoveryCodes();
|
||||
const today = new Date();
|
||||
oldCodes[oldCodes.indexOf(usedCode)] = today.toJSON().replace(/-/g, '/');
|
||||
setRecoveryCodes(oldCodes.toString());
|
||||
@ -55,7 +55,7 @@ function verifyRecoveryCode(recoveryCodeGuess: string) {
|
||||
|
||||
const recoveryCodes = getRecoveryCodes();
|
||||
let loginSuccess = false;
|
||||
recoveryCodes.forEach((recoveryCode: string) => {
|
||||
recoveryCodes.forEach((recoveryCode) => {
|
||||
if (recoveryCodeGuess === recoveryCode) {
|
||||
removeRecoveryCode(recoveryCode);
|
||||
loginSuccess = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user