wstrange / GoogleAuth

Google Authenticator Server side code
BSD 3-Clause "New" or "Revised" License
1.05k stars 330 forks source link

Unable to authorize codes that have a leading zero #70

Closed paulhirschi closed 6 years ago

paulhirschi commented 6 years ago

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
paulhirschi commented 6 years ago

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.