Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use lowercase email to fetch user #301

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading