[MINOR] Fix Email Updates (#17620)

* Fix Email

* Fix Test

(cherry picked from commit a9a1a2036b55fb2cf03c6535733059d364ef6310)
This commit is contained in:
Mohit Yadav 2024-08-29 11:59:00 +05:30 committed by mohitdeuex
parent aff2adbb98
commit c23fdc88b4
2 changed files with 3 additions and 4 deletions

View File

@ -578,7 +578,7 @@ public class UserRepository extends EntityRepository<User> {
@Override
public void entitySpecificUpdate() {
// LowerCase Email
updated.setEmail(updated.getEmail().toLowerCase());
updated.setEmail(original.getEmail().toLowerCase());
// Updates
updateRoles(original, updated);
@ -590,7 +590,6 @@ public class UserRepository extends EntityRepository<User> {
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);
}

View File

@ -305,13 +305,13 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
// 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);