Skip to content

Commit

Permalink
cherry pick for #23920 (#24205)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbishel authored Aug 8, 2023
1 parent 76e91df commit 7a32dd9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 1 addition & 12 deletions store/sqlstore/user_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion store/storetest/user_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7a32dd9

Please sign in to comment.