Skip to content

Commit c13ef2f

Browse files
author
VuXfi
committed
fix login otp check
1 parent 89516fd commit c13ef2f

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

models/User.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,10 @@ let Model = {
322322
// Check OTP
323323
let checkOTPResult = false;
324324
if (Boolean(OTP) && typeof OTP === "string" && OTP.length > 0) {
325-
if (await OneTimePassword.check(login, OTP)) {
326-
checkOTPResult = true;
327-
}
325+
checkOTPResult = await OneTimePassword.check(login, OTP);
328326
}
329327
// When password required and LOGIN_OTP_REQUIRED you should pass both
330-
if (await Settings.get("LOGIN_OTP_REQUIRED") && !checkOTPResult && passwordPolicy === "required")
328+
if (await Settings.get("LOGIN_OTP_REQUIRED") && !checkOTPResult)
331329
throw `login OTP check failed`;
332330
// When password is disabled Login possibly only by OTP
333331
if (passwordPolicy === "disabled" && !checkOTPResult)

models/User.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,11 @@ let Model = {
355355
// Check OTP
356356
let checkOTPResult = false;
357357
if (Boolean(OTP) && typeof OTP === "string" && OTP.length > 0) {
358-
if(await OneTimePassword.check(login, OTP)) {
359-
checkOTPResult = true
360-
}
358+
checkOTPResult = await OneTimePassword.check(login, OTP)
361359
}
362360

363361
// When password required and LOGIN_OTP_REQUIRED you should pass both
364-
if (await Settings.get("LOGIN_OTP_REQUIRED") && !checkOTPResult && passwordPolicy === "required") throw `login OTP check failed`
362+
if (await Settings.get("LOGIN_OTP_REQUIRED") && !checkOTPResult) throw `login OTP check failed`
365363

366364
// When password is disabled Login possibly only by OTP
367365
if (passwordPolicy === "disabled" && !checkOTPResult) throw `Password policy [disabled] (OTP check failed)`

0 commit comments

Comments
 (0)