Skip to content

Commit

Permalink
require regenerate invite id to have invite permission (#27427) (#27522)
Browse files Browse the repository at this point in the history
Automatic Merge
  • Loading branch information
mattermost-build authored Jul 2, 2024
1 parent 57f9796 commit e6a5d03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/channels/api4/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ func regenerateTeamInviteId(c *Context, w http.ResponseWriter, r *http.Request)
c.SetPermissionError(model.PermissionManageTeam)
return
}
if !c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), c.Params.TeamId, model.PermissionInviteUser) {
c.SetPermissionError(model.PermissionInviteUser)
return
}

auditRec := c.MakeAuditRecord("regenerateTeamInviteId", audit.Fail)
audit.AddEventParameter(auditRec, "team_id", c.Params.TeamId)
Expand Down
5 changes: 5 additions & 0 deletions server/channels/api4/team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,11 @@ func TestRegenerateTeamInviteId(t *testing.T) {
assert.NotEqual(t, team.InviteId, rteam.InviteId)
assert.NotEqual(t, team.InviteId, "")
assert.Equal(t, rteam.Email, "")

manager := th.SystemManagerClient
th.RemovePermissionFromRole(model.PermissionInviteUser.Id, model.SystemManagerRoleId)
_, _, err = manager.RegenerateTeamInviteId(context.Background(), team.Id)
require.Error(t, err)
}

func TestSoftDeleteTeam(t *testing.T) {
Expand Down

0 comments on commit e6a5d03

Please sign in to comment.