Skip to content

Commit

Permalink
use lowercase email to fetch user (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgunnCO authored Apr 30, 2024
1 parent e1b087c commit 7025063
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,14 @@ public ResponseEntity<String> updateFundingOrganisation(@RequestBody UpdateFundi
public ResponseEntity<Void> checkNewAdminEmailIsValid(
@RequestBody @Valid final CheckNewAdminEmailDto checkNewAdminEmailDto, final HttpServletRequest request) {
// the email we store comes from One Login, which will always convert the value the user entered to lowercase
if (checkNewAdminEmailDto.getEmailAddress().toLowerCase().equals(checkNewAdminEmailDto.getOldEmailAddress())) {
final String newAdminEmail = checkNewAdminEmailDto.getEmailAddress().toLowerCase();
if (newAdminEmail.equals(checkNewAdminEmailDto.getOldEmailAddress())) {
throw new FieldViolationException("emailAddress", "This user already owns this grant.");
}

try {
final String jwt = HelperUtils.getJwtFromCookies(request, userServiceConfig.getCookieName());
userService.getGrantAdminIdFromUserServiceEmail(checkNewAdminEmailDto.getEmailAddress(), jwt);
userService.getGrantAdminIdFromUserServiceEmail(newAdminEmail, jwt);
}
catch (Exception e) {
throw new FieldViolationException("emailAddress", "Email address does not belong to an admin user");
Expand Down

0 comments on commit 7025063

Please sign in to comment.