[GH-ISSUE #158] Documentation for verifyKeyNewer is very misleading #68

Closed
opened 2026-02-25 20:32:20 +03:00 by kerem · 1 comment
Owner

Originally created by @jhoff on GitHub (Jul 21, 2020).
Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/158

I think the user that reported https://github.com/antonioribeiro/google2fa/issues/134 experienced the issue because the documentation is misleading:

$secret = $request->input('secret');

$timestamp = $google2fa->verifyKeyNewer($user->google2fa_secret, $secret, $user->google2fa_ts);

if ($timestamp !== false) {
    $user->update(['google2fa_ts' => $timestamp]);
    // successful
} else {
    // failed
}

If $user->google2fa_ts is set to null ( I.E for a new user ), then $timestamp will be returned as true not a timestamp

Also, it feels really misleading to refer to them as timestamps when they are a fraction of a real timestamp ( the quotient of a unix timestamp and the key regeneration value). Because of this I assumed I could make google2fa_ts a timestamp field in the database, when it should simply be an integer. I also tried to set the default value of google2fa_ts to now() to no avail.

Originally created by @jhoff on GitHub (Jul 21, 2020). Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/158 I think the user that reported https://github.com/antonioribeiro/google2fa/issues/134 experienced the issue because the documentation is misleading: ``` $secret = $request->input('secret'); $timestamp = $google2fa->verifyKeyNewer($user->google2fa_secret, $secret, $user->google2fa_ts); if ($timestamp !== false) { $user->update(['google2fa_ts' => $timestamp]); // successful } else { // failed } ``` If `$user->google2fa_ts` is set to null ( I.E for a new user ), then `$timestamp` will be returned as `true` not a timestamp Also, it feels really misleading to refer to them as `timestamps` when they are a fraction of a real timestamp ( the quotient of a unix timestamp and the key regeneration value). Because of this I assumed I could make `google2fa_ts` a timestamp field in the database, when it should simply be an integer. I also tried to set the default value of `google2fa_ts` to `now()` to no avail.
kerem closed this issue 2026-02-25 20:32:20 +03:00
Author
Owner

@jhoff commented on GitHub (Nov 12, 2020):

This is still a problem, but I'm cleaning house and no longer want to look at it.

<!-- gh-comment-id:725870787 --> @jhoff commented on GitHub (Nov 12, 2020): This is still a problem, but I'm cleaning house and no longer want to look at it.
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#68
No description provided.