Fix OTP time window

This commit is contained in:
KernelDeimos 2024-05-06 15:02:14 -04:00
parent 918eb3bb67
commit a628358c9f
3 changed files with 6 additions and 4 deletions

1
package-lock.json generated
View File

@ -13,7 +13,6 @@
"packages/*"
],
"dependencies": {
"otpauth": "9.2.4",
"uuid": "^9.0.1"
},
"devDependencies": {

View File

@ -43,7 +43,6 @@
]
},
"dependencies": {
"otpauth": "9.2.4",
"uuid": "^9.0.1"
}
}

View File

@ -48,8 +48,12 @@ class OTPService extends BaseService {
secret,
});
const ok = totp.validate({ token: code });
return ok;
const allowed = [-1, 0, 1];
const delta = totp.validate({ token: code });
if ( delta === null ) return false;
if ( ! allowed.includes(delta) ) return false;
return true;
}
gen_otp_secret_ () {