Unverified Commit 39bee5d8 authored by Mattermost Build's avatar Mattermost Build Committed by GitHub
Browse files

MM-27572 permissions regression (#15215) (#15222)

Automatic Merge
parent d47c6bd9
......@@ -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)
}
......
......@@ -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))
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment