diff --git a/app/authorization.go b/app/authorization.go index 4218823bf1..ca24c977b2 100644 --- a/app/authorization.go +++ b/app/authorization.go @@ -148,7 +148,9 @@ func (a *App) HasPermissionToTeam(askingUserId string, teamId string, permission } teamMember, _ := a.GetTeamMember(teamId, askingUserId) if teamMember != nil && teamMember.DeleteAt == 0 { - return a.RolesGrantPermission(teamMember.GetRoles(), permission.Id) + if a.RolesGrantPermission(teamMember.GetRoles(), permission.Id) { + return true + } } return a.HasPermissionTo(askingUserId, permission) } diff --git a/app/authorization_test.go b/app/authorization_test.go index 23af424d72..59a159c6bd 100644 --- a/app/authorization_test.go +++ b/app/authorization_test.go @@ -48,14 +48,14 @@ func TestHasPermissionToTeam(t *testing.T) { defer th.TearDown() assert.True(t, th.App.HasPermissionToTeam(th.BasicUser.Id, th.BasicTeam.Id, model.PERMISSION_LIST_TEAM_CHANNELS)) - th.RemoveUserFromTeam(th.BasicUser, th.BasicTeam) - assert.False(t, th.App.HasPermissionToTeam(th.BasicUser.Id, th.BasicTeam.Id, model.PERMISSION_LIST_TEAM_CHANNELS)) + assert.True(t, th.App.HasPermissionToTeam(th.SystemAdminUser.Id, th.BasicTeam.Id, model.PERMISSION_LIST_TEAM_CHANNELS)) th.LinkUserToTeam(th.SystemAdminUser, th.BasicTeam) assert.True(t, th.App.HasPermissionToTeam(th.SystemAdminUser.Id, th.BasicTeam.Id, model.PERMISSION_LIST_TEAM_CHANNELS)) + th.RemovePermissionFromRole(model.PERMISSION_LIST_TEAM_CHANNELS.Id, model.TEAM_USER_ROLE_ID) + assert.True(t, th.App.HasPermissionToTeam(th.SystemAdminUser.Id, th.BasicTeam.Id, model.PERMISSION_LIST_TEAM_CHANNELS)) th.RemoveUserFromTeam(th.SystemAdminUser, th.BasicTeam) - // This used to fail before MM-26015 assert.True(t, th.App.HasPermissionToTeam(th.SystemAdminUser.Id, th.BasicTeam.Id, model.PERMISSION_LIST_TEAM_CHANNELS)) }