Skip to content

Commit

Permalink
MM-55006 Validate team access before returning deleted teams (#25226) (
Browse files Browse the repository at this point in the history
…#25519)

Automatic Merge
  • Loading branch information
mattermost-build committed Nov 22, 2023
1 parent 6f5e8d9 commit 9e52296
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/channels/api4/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,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
Expand Down
6 changes: 6 additions & 0 deletions server/channels/api4/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9e52296

Please sign in to comment.