DarkGhostHunter / Laraguard

"On-premises 2FA Authentication for all your users out-of-the-box
MIT License
266 stars 24 forks source link

Invalid codes #8

Closed padre closed 4 years ago

padre commented 4 years ago

I cannot enable Two Factor Authentication because the code generated by my authentication application does not match the value generated by the generateCode() function.

When I scan the QR code to confirm enablement the validateCode() function always returns false because the code is not valid.

I had to debug the value returned by $this->makeCode($at, -$i) and use it to be able to enable it.

Otherwise, thank you very much for this great package. I was able to use all the features.

But validateCode always returns false because the code doesn't match my authentication application :-(

DarkGhostHunter commented 4 years ago

Let me check one thing. May be I f*cked up the code generation between commits.

DarkGhostHunter commented 4 years ago

Can confirm, I f*cked up the code generation:

image

DarkGhostHunter commented 4 years ago

Fixed in #9

padre commented 4 years ago

Great! It works!

Thanks a lot!

DarkGhostHunter commented 4 years ago

Great! It works!

Thanks a lot!

If you're curious, the code was originally coded using the timestamp like 15812345678, while it should be coded using the periods (timestamp divided by X seconds), like 527078189.

I fixed that in the code, but on the function that generates the code. You can still use the timestamp to check other codes at a given time. The timestamp will get automatically converted to the corresponding period, since this is a TOTP-focused package.