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.
Этот коммит содержится в:
Miguel de la Cruz
2024-06-13 09:56:39 +02:00
коммит произвёл GitHub
родитель 4b0ae20ef7
Коммит 9733694854

Просмотреть файл

@@ -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