mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-55006 Validate team access before returning deleted teams (#25226)
* validate team access before returning deleted teams * update error return * Update channel.go --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
52b485b369
commit
f67f0bd220
@ -835,6 +835,11 @@ func getDeletedChannelsForTeam(c *Context, w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
if !c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), c.Params.TeamId, model.PermissionListTeamChannels) {
|
||||
c.SetPermissionError(model.PermissionListTeamChannels)
|
||||
return
|
||||
}
|
||||
|
||||
channels, err := c.App.GetDeletedChannels(c.AppContext, c.Params.TeamId, c.Params.Page*c.Params.PerPage, c.Params.PerPage, c.AppContext.Session().UserId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
|
@ -952,6 +952,12 @@ func TestGetDeletedChannelsForTeam(t *testing.T) {
|
||||
channels, _, err = client.GetDeletedChannelsForTeam(context.Background(), team.Id, 1, 1, "")
|
||||
require.NoError(t, err)
|
||||
require.Len(t, channels, 1, "should be one channel per page")
|
||||
|
||||
// test non team member
|
||||
th.SystemAdminClient.RemoveTeamMember(context.Background(), team.Id, th.BasicUser.Id)
|
||||
_, resp, err := client.GetDeletedChannelsForTeam(context.Background(), team.Id, 0, 100, "")
|
||||
require.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestGetPrivateChannelsForTeam(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user