Allow login with previous 2FA code as well, closes #163.
This commit is contained in:
parent
e1bb58027c
commit
68db9ce243
1 changed files with 3 additions and 1 deletions
|
@ -42,9 +42,11 @@ while (!empty($twofactor->value('array'))) {
|
|||
break;
|
||||
}
|
||||
|
||||
$givenCode = $twofactor->code->value('string', '');
|
||||
$currentCode = totp_generate($tokenInfo['user_totp_key']);
|
||||
$previousCode = totp_generate($tokenInfo['user_totp_key'], time() - 30);
|
||||
|
||||
if ($currentCode !== $twofactor->code->value('string', '')) {
|
||||
if ($currentCode !== $givenCode && $previousCode !== $givenCode) {
|
||||
$notices[] = sprintf(
|
||||
"Invalid two factor code, %d attempt%s remaining",
|
||||
$remainingAttempts - 1,
|
||||
|
|
Loading…
Add table
Reference in a new issue