Closed JonathanNet closed 2 years ago
Works for me:
>>> use Vectorface\GoogleAuthenticator;
>>> $ga = new GoogleAuthenticator();
=> Vectorface\GoogleAuthenticator {#3412}
>>> $secret = $ga->createSecret();
=> "Y6JHZFCHJSFDF2NR"
>>> $oneCode = $ga->getCode($secret);
=> "028988"
>>> $checkResult = $ga->verifyCode($secret, $oneCode, 2);
=> true
I see you're using integer
validation. That's not correct, because OTP codes can start with zeroes (as you can see in my example above), which if converted to an integer would just be 28988
instead of "028988"
.
The verifyCode
method expects a string which only contains numbers, but
it's not a "valid number" in of itself because of the padded zeroes.
I'll close this for now, I'm not seeing a problem and I have to assume this was a mistake in your code and not a problem with the library.
If you can dig deeper and find and actual problem that you can prove is the library's fault, we can reopen.
Hi I am tring to get this working, but it allways return false, also then the code is right, is it a bug or something?
` $data = $this->validate($request, [ 'otp' => ['nullable', 'integer',], ]);