Fix for possible NPE.

This commit is contained in:
FireMasterK 2021-10-03 09:55:13 +01:00
parent 08aeefa099
commit d03c677a7f
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD

View file

@ -578,15 +578,14 @@ public class ResponseHelper {
User dbuser = s.createQuery(cr).uniqueResult(); User dbuser = s.createQuery(cr).uniqueResult();
String hash = dbuser.getPassword();
if (dbuser != null) { if (dbuser != null) {
if (hash.startsWith("$argon2") && argon2PasswordEncoder.matches(pass, hash)) { String hash = dbuser.getPassword();
if (hash.startsWith("$argon2")) {
if (argon2PasswordEncoder.matches(pass, hash)) {
s.close(); s.close();
return Constants.mapper.writeValueAsBytes(new LoginResponse(dbuser.getSessionId())); return Constants.mapper.writeValueAsBytes(new LoginResponse(dbuser.getSessionId()));
} }
} else if (bcryptPasswordEncoder.matches(pass, hash)) {
if (bcryptPasswordEncoder.matches(pass, hash)) {
s.close(); s.close();
return Constants.mapper.writeValueAsBytes(new LoginResponse(dbuser.getSessionId())); return Constants.mapper.writeValueAsBytes(new LoginResponse(dbuser.getSessionId()));
} }