Updates remote user creation process to preserve username and email (#27334)

This change makes sure that the original username and email are always
preserved when creating a user coming from a remote cluster.
This commit is contained in:
Miguel de la Cruz 2024-06-13 09:56:39 +02:00 committed by GitHub
parent 4b0ae20ef7
commit 9733694854
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -249,13 +249,9 @@ func (scs *Service) insertSyncUser(rctx request.CTX, user *model.User, _ *model.
// ensure the new user is created with system_user role and random password.
user = sanitizeUserForSync(user)
// save the original username and email in props (if not already done by another remote)
if _, ok := user.GetProp(KeyRemoteUsername); !ok {
user.SetProp(KeyRemoteUsername, user.Username)
}
if _, ok := user.GetProp(KeyRemoteEmail); !ok {
user.SetProp(KeyRemoteEmail, user.Email)
}
// save the original username and email in props
user.SetProp(KeyRemoteUsername, user.Username)
user.SetProp(KeyRemoteEmail, user.Email)
// Apply a suffix to the username until it is unique. Collisions will be quite
// rare since we are joining a username that is unique at a remote site with a unique