Skip to content

Commit

Permalink
Load userExists only when it is required
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Nuyanzin <[email protected]>
  • Loading branch information
snuyanzin authored Jan 17, 2024
1 parent 7482fe5 commit 090959a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions core/src/main/java/io/aiven/klaw/helpers/UtilMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ public Integer getNextSeqIdAndUpdate(String entityName, int tenantId) {

public String insertIntoRegisterUsers(RegisterUserInfo userInfo) {
log.debug("insertIntoRegisterUsers {}", userInfo.getUsername());
Optional<RegisterUserInfo> userExists = registerInfoRepo.findById(userInfo.getUsername());

Optional<UserInfo> userNameExists = userInfoRepo.findById(userInfo.getUsername());
if (userNameExists.isPresent()) return "Failure. User already exists";

// STAGING status comes from AD users
Optional<RegisterUserInfo> userExists = registerInfoRepo.findById(userInfo.getUsername());
if (userExists.isPresent()) {
if ("APPROVED".equals(userExists.get().getStatus())) {
// do nothing -- user is deleted
Expand Down

0 comments on commit 090959a

Please sign in to comment.