stupid me

This commit is contained in:
muhammadeko 2022-05-23 19:15:08 +07:00
parent a512478cfc
commit ac1c4b57d2
No known key found for this signature in database
GPG Key ID: 51366716C10E98B1

View File

@ -56,16 +56,17 @@ public final class Authentication {
}
public static String generateOTP(Account account) {
String token = Authentication.generateRandomNumber(6);
Authentication.otps.put(token, account.getUsername());
return token;
String otp = Authentication.generateRandomNumber(6);
while (otps.containsKey(otp)) {
GCAuth.getInstance().getLogger().info("OTP already in use, generating new one");
otp = Authentication.generateRandomNumber(6);
}
Authentication.otps.put(otp, account.getUsername());
return otp;
}
public static String generateJwt(Account account) {
String otp = generateOTP(account);
while (otps.get(otp) != null) {
otp = generateOTP(account);
}
watchOTP(otp);
return JWT.create()
.withClaim("token", otp)