Skip to content

Commit

Permalink
Merge pull request #115 from georchestra/email_authenticated_issue_af…
Browse files Browse the repository at this point in the history
…ter_email_change

Fixed issue for authenticated by email users who change their email
  • Loading branch information
emmdurin committed Apr 3, 2024
2 parents 7344454 + cf5b59c commit 5039f9e
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 5039f9e

Please sign in to comment.