MM-59540 Ensure user has invite team permission in order to change setting (#28670)

* ensure user has invite team permission in order to change setting

* add tests and handle UI

* lint fixes

* revert changes to invite section input

* update tests

* revert bad merge

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Scott Bishel
2024-11-20 16:02:32 -07:00
коммит произвёл GitHub
родитель 11b66de686
Коммит 790103fae0
5 изменённых файлов: 78 добавлений и 3 удалений

Просмотреть файл

@@ -251,6 +251,12 @@ func patchTeam(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
// if changing "AllowOpenInvite" or "AllowedDomains", user must have InviteUser permission
if (team.AllowOpenInvite != nil || team.AllowedDomains != nil) && !c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), c.Params.TeamId, model.PermissionInviteUser) {
c.SetPermissionError(model.PermissionInviteUser)
return
}
if oldTeam, err := c.App.GetTeam(c.Params.TeamId); err == nil {
auditRec.AddEventPriorState(oldTeam)
auditRec.AddEventObjectType("team")