Feat v0.7.8 bug fixes admin gaps (#62)
All checks were successful
CI/CD / detect-changes (push) Successful in 5s
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m49s
CI/CD / build-and-deploy (push) Successful in 29s
CI/CD / test-sqlite (push) Successful in 2m55s
All checks were successful
CI/CD / detect-changes (push) Successful in 5s
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m49s
CI/CD / build-and-deploy (push) Successful in 29s
CI/CD / test-sqlite (push) Successful in 2m55s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #62.
This commit is contained in:
@@ -149,8 +149,24 @@ func (h *WorkflowHandler) Update(c *gin.Context) {
|
||||
|
||||
// Delete deletes a workflow and all its stages/versions (CASCADE).
|
||||
// DELETE /api/v1/workflows/:id
|
||||
// Admin-only: only allows deleting global (team_id IS NULL) workflows.
|
||||
// Team-scoped workflows must be deleted via the team endpoint.
|
||||
func (h *WorkflowHandler) Delete(c *gin.Context) {
|
||||
if err := h.stores.Workflows.Delete(c.Request.Context(), c.Param("id")); err != nil {
|
||||
ctx := c.Request.Context()
|
||||
wfID := c.Param("id")
|
||||
|
||||
// Guard: prevent accidental deletion of team-scoped workflows from the admin endpoint
|
||||
wf, err := h.stores.Workflows.GetByID(ctx, wfID)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "workflow not found"})
|
||||
return
|
||||
}
|
||||
if wf.TeamID != nil {
|
||||
c.JSON(http.StatusForbidden, gin.H{"error": "team-scoped workflows must be deleted via the team endpoint"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.stores.Workflows.Delete(ctx, wfID); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to delete workflow"})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user