Skip to content

Commit

Permalink
Simplify permissions check (#1902)
Browse files Browse the repository at this point in the history
  • Loading branch information
crspeller committed Apr 10, 2024
1 parent 939af55 commit 14eb874
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 0 additions & 11 deletions server/api/playbook_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1318,17 +1318,6 @@ func (h *PlaybookRunHandler) itemRun(c *Context, w http.ResponseWriter, r *http.
return
}

playbookRun, err := h.playbookRunService.GetPlaybookRun(vars["id"])
if err != nil {
h.HandleError(w, c.logger, err)
return
}

if !h.pluginAPI.User.HasPermissionToChannel(userID, playbookRun.ChannelID, model.PermissionCreatePost) {
h.HandleErrorWithCode(w, c.logger, http.StatusForbidden, "user does not have permission to channel", nil)
return
}

triggerID, err := h.playbookRunService.RunChecklistItemSlashCommand(playbookRunID, userID, checklistNum, itemNum)
if err != nil {
h.HandleError(w, c.logger, err)
Expand Down
4 changes: 4 additions & 0 deletions server/app/playbook_run_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,10 @@ func (s *PlaybookRunServiceImpl) RunChecklistItemSlashCommand(playbookRunID, use
return "", err
}

if !s.pluginAPI.User.HasPermissionToChannel(userID, playbookRun.ChannelID, model.PermissionCreatePost) {
return "", errors.New("user does not have permission to channel")
}

if !IsValidChecklistItemIndex(playbookRun.Checklists, checklistNumber, itemNumber) {
return "", errors.New("invalid checklist item indices")
}
Expand Down

0 comments on commit 14eb874

Please sign in to comment.