Skip to content

Commit

Permalink
fixed issue for authenticated by email users who change their email
Browse files Browse the repository at this point in the history
  • Loading branch information
emmdurin committed Apr 2, 2024
1 parent 7344454 commit cf5b59c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ public Optional<ExtendedGeorchestraUser> findByUsername(@NonNull String serviceN
return extend(serviceName, user);
}

public Optional<ExtendedGeorchestraUser> findByEmail(@NonNull String serviceName, @NonNull String email) {
UsersApi usersApi = usersByConfigName.get(serviceName);
Objects.requireNonNull(usersApi, () -> "No UsersApi found for config named " + serviceName);
Optional<GeorchestraUser> user = usersApi.findByEmail(email);
return extend(serviceName, user);
}

private Optional<ExtendedGeorchestraUser> extend(String serviceName, Optional<GeorchestraUser> user) {
OrganizationsApi orgsApi = orgsByConfigName.get(serviceName);
Objects.requireNonNull(orgsApi, () -> "No OrganizationsApi found for config named " + serviceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
}
Assert.notNull(password, "Null password was supplied in authentication token");
DirContextOperations userData = doAuthentication(userToken);
UserDetails user = this.userDetailsContextMapper.mapUserFromContext(userData, authentication.getName(),
UserDetails user = this.userDetailsContextMapper.mapUserFromContext(userData, username,
loadUserAuthorities(userData, authentication.getName(), (String) authentication.getCredentials()));

return createSuccessfulAuthentication(userToken, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ Optional<GeorchestraUser> map(GeorchestraUserNamePasswordAuthenticationToken tok
final String username = principal.getUsername();

Optional<ExtendedGeorchestraUser> user = users.findByUsername(ldapConfigName, username);
if (user.isEmpty()) {
user = users.findByEmail(ldapConfigName, username);
}

return user.map(u -> fixPrefixedRoleNames(u, token));
}

Expand Down

0 comments on commit cf5b59c

Please sign in to comment.