mirror of
https://github.com/antonioribeiro/google2fa.git
synced 2026-04-26 08:35:54 +03:00
[GH-ISSUE #102] Uncaught Error: Call to a member function input() on null in #513
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/google2fa#513
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Apr 8, 2018).
Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/102
I have sort of the same problem as what JordyKroeze had. Even if I have entered the TOTP from Authenticator Plus after I scanned the QR code, it only generate
Uncaught Error: Call to a member function input() on null in .... Why?Here's is my current code:
@nztim commented on GitHub (Apr 9, 2018):
$secret = $request->input('secret');is an example of how to get the user input. In your code, the equivalent line is$input = $_POST['textfield-verify-code'];so you would supply$inputto the verifyKey method as the secret.There is another issue with the code:
If you generate a new, random secret key the user input won't verify against it.
$tfa_secretkeyneeds to have been the one the user previously scanned into their authentication app.In the documentation it looks like this:
$user->google2fa_secretis referring to the user's existing secret key.@ghost commented on GitHub (Apr 9, 2018):
Thank you, but I keep getting the same error message. Have I missed something?
UPDATE 1
I got now a new error message from the code below:
Uncaught PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException: Secret key is too short. Must be at least 16 base32 characters inUPDATE 2
I have read your answer once more and changed a lot in my code. Still, I'm getting the same error message as in update 1.
site-settings.php
site-settings-twfa.php
If I change
$secretKey = $google2fa->generateSecretKey(64);to the following:I'll get the following error message:
@nztim commented on GitHub (Apr 9, 2018):
I think the first code block looked good apart from the
$secret = $request->input('secret');Update 1: the user input will not be able to validate against a secret key that has been just created. If
$user->google2fa_secretis not defined that would explain the error.Update 2: The first two code blocks have issues but this should work, check that everything is defined:
The last error is caused by the code not producing a GA-compatible secret key. Applying the solution provided in the docs:
My suggestion would be to keep things as simple as possible to start with in order to get it working properly. Just do the bare minimum with defaults and go from there.
@ghost commented on GitHub (Apr 9, 2018):
Thank you for your answer. Unfortunately I'll get the same error message when I tested your code. Everything is defined, as you can see in
UPDATE 1.I tested to add
$google2fa->setEnforceGoogleAuthenticatorCompatibility(false);which removed the error message that is mentioned inUPDATE 2. I scanned the QR-code that had this key:GFMFQWCYLBMFQWCYLBMFQWCYLASYUJG2A5YY5I7XJFWPOL27OAHFQN6DZ7. After that, I tested to enter the TOTP from the app. Here's the result from the console:site-settings.php
I am sorry, but I am totally new to this kind of security method.
@nztim commented on GitHub (Apr 9, 2018):
H:\www\min-ekonomi\ajax\post\save-settings-twfa.php(16): PragmaRX\Google2FA\Google2FA->verifyKey(NULL, '273234', 4)That looks to me like you called
verifyKey()with NULL as the secret key. Check the value of the secret key before this is called.@ghost commented on GitHub (Apr 9, 2018):
Aha! The file couldn't fetch user's information. That is now fixed, but it still give me an error message.
@nztim commented on GitHub (Apr 9, 2018):
Can you just use
$secretKey = $google2fa->generateSecretKey();to get things working?@ghost commented on GitHub (Apr 9, 2018):
Oh my! Now it's finally working! Many thanks for your help!
@NaysKutzu commented on GitHub (Dec 8, 2023):
it is not Secret key is too short. Must be at least 16 base32 characters