diff --git a/store/sqlstore/user_store.go b/store/sqlstore/user_store.go index 8d9093e08f..ddc68cc0d0 100644 --- a/store/sqlstore/user_store.go +++ b/store/sqlstore/user_store.go @@ -2028,19 +2028,8 @@ func (us SqlUserStore) DemoteUserToGuest(userID string) (_ *model.User, err erro return nil, err } - roles := user.GetRoles() - - newRoles := []string{} - for _, role := range roles { - if role == model.SystemUserRoleId { - newRoles = append(newRoles, model.SystemGuestRoleId) - } else if role != model.SystemAdminRoleId { - newRoles = append(newRoles, role) - } - } - curTime := model.GetMillis() - newRolesDBStr := strings.Join(newRoles, " ") + newRolesDBStr := model.SystemGuestRoleId query := us.getQueryBuilder().Update("Users"). Set("Roles", newRolesDBStr). Set("UpdateAt", curTime). diff --git a/store/storetest/user_store.go b/store/storetest/user_store.go index 138c3cfb14..566a145dca 100644 --- a/store/storetest/user_store.go +++ b/store/storetest/user_store.go @@ -5724,7 +5724,7 @@ func testUserStoreDemoteUserToGuest(t *testing.T, ss store.Store) { updatedUser, err := ss.User().DemoteUserToGuest(user.Id) require.NoError(t, err) - require.Equal(t, "system_guest custom_role", updatedUser.Roles) + require.Equal(t, "system_guest", updatedUser.Roles) updatedTeamMember, nErr := ss.Team().GetMember(context.Background(), teamId, user.Id) require.NoError(t, nErr)