wstrange / GoogleAuth

Google Authenticator Server side code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to authorize codes that have a leading zero

paulhirschi opened this issue · comments

Because they are typed to be an int, attempting to authorize a code that has a leading zero will throw an exception. Leading zeros aren't allowed in non-decimal numbers.

[ERROR] GoogleAuth/src/test/java/com/warrenstrange/googleauth/GoogleAuthTest.java:[66,48] integer number too large: 098775

Integer.parseInt("098775") = 98775 will authenticate just fine. Collect user input as a String, parse it as an int for verification will correctly authenticate TOTP codes with a leading zero.