Allow login with previous 2FA code as well, closes #163.

This commit is contained in:
flash 2019-03-18 13:17:46 +01:00
parent e1bb58027c
commit 68db9ce243

View file

@ -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,