[GH-ISSUE #134] Null values on verifyKeyNewer regression #531

Closed
opened 2026-03-14 12:08:10 +03:00 by kerem · 1 comment
Owner

Originally created by @williamhector on GitHub (Jan 28, 2020).
Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/134

When a user account is logging in for the first time and they don't yet have an old timestamp to provide to verifyKeyNewer, calling it doesn't get a new timestamp returned for next time either, only a true value.

This seems to have been previously addressed in #70 and 592ca6f021 and then regressed in ffdcb8231d with the change back to using is_null($oldTimestamp) in findValidOTP.

Current workaround for me is to check if the result of verifyKeyNewer is true and if so, set the user's 2fa timestamp to the result of getTimestamp.

Originally created by @williamhector on GitHub (Jan 28, 2020). Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/134 When a user account is logging in for the first time and they don't yet have an old timestamp to provide to `verifyKeyNewer`, calling it doesn't get a new timestamp returned for next time either, only a `true` value. This seems to have been previously addressed in #70 and 592ca6f021b950b2eb39a05ed33913613888d66d and then regressed in ffdcb8231d0a19d0cda9b188e799dd6b8d9014db with the change back to using `is_null($oldTimestamp)` in `findValidOTP`. Current workaround for me is to check if the result of `verifyKeyNewer` is `true` and if so, set the user's 2fa timestamp to the result of `getTimestamp`.
kerem closed this issue 2026-03-14 12:08:15 +03:00
Author
Owner

@antonioribeiro commented on GitHub (Apr 4, 2020):

@williamhector, this is actually the behavior of findValidOTP, since forever:

https://github.com/antonioribeiro/google2fa/blob/8.x/src/Google2FA.php#L83

<!-- gh-comment-id:609044772 --> @antonioribeiro commented on GitHub (Apr 4, 2020): @williamhector, this is actually the behavior of `findValidOTP`, since forever: https://github.com/antonioribeiro/google2fa/blob/8.x/src/Google2FA.php#L83
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/google2fa#531
No description provided.