From 9733694854f972a8055ddf26ffdc9df4699faae9 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Thu, 13 Jun 2024 09:56:39 +0200 Subject: [PATCH] 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. --- server/platform/services/sharedchannel/sync_recv.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server/platform/services/sharedchannel/sync_recv.go b/server/platform/services/sharedchannel/sync_recv.go index 643d1bdbd8..10ce94613d 100644 --- a/server/platform/services/sharedchannel/sync_recv.go +++ b/server/platform/services/sharedchannel/sync_recv.go @@ -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