Skip to content

Commit

Permalink
[MINOR] Fix Email Updates (#17620)
Browse files Browse the repository at this point in the history
* Fix Email

* Fix Test
  • Loading branch information
mohityadav766 committed Aug 29, 2024
1 parent 23096fa commit a9a1a20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public UserUpdater(User original, User updated, Operation operation) {
@Override
public void entitySpecificUpdate() {
// LowerCase Email
updated.setEmail(updated.getEmail().toLowerCase());
updated.setEmail(original.getEmail().toLowerCase());

// Updates
updateRoles(original, updated);
Expand All @@ -590,7 +590,6 @@ public void entitySpecificUpdate() {
recordChange("timezone", original.getTimezone(), updated.getTimezone());
recordChange("isBot", original.getIsBot(), updated.getIsBot());
recordChange("isAdmin", original.getIsAdmin(), updated.getIsAdmin());
recordChange("email", original.getEmail(), updated.getEmail().toLowerCase());
recordChange("isEmailVerified", original.getIsEmailVerified(), updated.getIsEmailVerified());
updateAuthenticationMechanism(original, updated);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@ void put_validUser_200_ok() throws IOException {

// Update the user information using PUT
String oldEmail = create.getEmail();
// Even with new field being updated, this shouuld not take effect
CreateUser update = create.withEmail("user.xyz@email.com").withDisplayName("displayName1");

ChangeDescription change = getChangeDescription(user, MINOR_UPDATE);
fieldAdded(change, "displayName", "displayName1");
fieldUpdated(change, "email", oldEmail, "user.xyz@email.com");
user = updateAndCheckEntity(update, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);

assertEquals(oldEmail, user.getEmail());
// Update the user information using PUT as the logged-in user
update = create.withDisplayName("displayName2");
change = getChangeDescription(user, MINOR_UPDATE);
Expand Down

0 comments on commit a9a1a20

Please sign in to comment.