diff --git a/core/src/main/java/io/aiven/klaw/helpers/UtilMethods.java b/core/src/main/java/io/aiven/klaw/helpers/UtilMethods.java index 8920e45019..c1a00bd378 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/UtilMethods.java +++ b/core/src/main/java/io/aiven/klaw/helpers/UtilMethods.java @@ -22,8 +22,7 @@ @Slf4j public class UtilMethods { public static String getUserName(Object principal, String preferredUsername) { - if (principal instanceof DefaultOAuth2User) { - DefaultOAuth2User defaultOAuth2User = (DefaultOAuth2User) principal; + if (principal instanceof DefaultOAuth2User defaultOAuth2User) { return (String) defaultOAuth2User.getAttributes().get(preferredUsername); } else if (principal instanceof String) { return (String) principal; diff --git a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java index c972253900..57a7cb6395 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java +++ b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java @@ -375,12 +375,12 @@ public Integer getNextSeqIdAndUpdate(String entityName, int tenantId) { public String insertIntoRegisterUsers(RegisterUserInfo userInfo) { log.debug("insertIntoRegisterUsers {}", userInfo.getUsername()); - Optional userExists = registerInfoRepo.findById(userInfo.getUsername()); Optional userNameExists = userInfoRepo.findById(userInfo.getUsername()); if (userNameExists.isPresent()) return "Failure. User already exists"; // STAGING status comes from AD users + Optional userExists = registerInfoRepo.findById(userInfo.getUsername()); if (userExists.isPresent()) { if ("APPROVED".equals(userExists.get().getStatus())) { // do nothing -- user is deleted