Skip to content

Commit

Permalink
return a better error when mutation access is not allowed (#68)
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Funkhouser <[email protected]>
  • Loading branch information
golanglemonade authored Nov 14, 2024
1 parent d306020 commit 4c373cf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions entfga/templates/authzChecks.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
"github.com/theopenlane/iam/auth"
)

var (
ErrPermissionDenied = errors.New("you are not authorized to perform this action")
)

{{- $nodes := .Graph.Nodes }}

{{- range $n := $nodes }}
Expand Down Expand Up @@ -190,8 +194,8 @@ import (
return privacy.Allow
}

// deny if it was a mutation is not allowed
return privacy.Deny
// return error if the action is not allowed
return ErrPermissionDenied
}

func (m *{{ $mutator }}) CheckAccessForDelete(ctx context.Context) error {
Expand Down Expand Up @@ -230,8 +234,8 @@ import (
return privacy.Allow
}

// deny if it was a mutation is not allowed
return privacy.Deny
// return error if the action is not allowed
return ErrPermissionDenied
}
{{- end }}
{{- end }}
Expand Down

0 comments on commit 4c373cf

Please sign in to comment.