chore: add actor to policy errors for later use

This commit is contained in:
Zach Daniel 2024-08-13 10:10:49 -04:00
parent f0c6e86d45
commit 622561dc90
2 changed files with 6 additions and 0 deletions

View file

@ -11,6 +11,7 @@ defmodule Ash.Error.Forbidden.Policy do
scenarios: [],
facts: %{},
filter: nil,
actor: nil,
policy_breakdown?: false,
must_pass_strict_check?: false,
for_fields: nil,

View file

@ -484,6 +484,7 @@ defmodule Ash.Policy.Authorizer do
policies: Map.get(state, :policies),
resource: Map.get(state, :resource),
action: Map.get(state, :action),
actor: Map.get(state, :actor),
changeset_doesnt_match_filter: true,
filter: filter
)
@ -496,6 +497,7 @@ defmodule Ash.Policy.Authorizer do
policies: Map.get(state, :policies),
resource: Map.get(state, :resource),
action: Map.get(state, :action),
actor: Map.get(state, :actor),
must_pass_strict_check?: true
)
end
@ -507,6 +509,7 @@ defmodule Ash.Policy.Authorizer do
policies: Map.get(state, :policies),
resource: Map.get(state, :resource),
action: Map.get(state, :action),
actor: Map.get(state, :actor),
must_pass_strict_check?: true
)
end
@ -1507,6 +1510,7 @@ defmodule Ash.Policy.Authorizer do
context_description: opts[:context_description],
for_fields: opts[:for_fields],
resource: Map.get(authorizer, :resource),
actor: Map.get(authorizer, :action),
action: Map.get(authorizer, :action),
scenarios: []
)}
@ -1529,6 +1533,7 @@ defmodule Ash.Policy.Authorizer do
for_fields: opts[:for_fields],
resource: Map.get(authorizer, :resource),
action: Map.get(authorizer, :action),
actor: Map.get(authorizer, :action),
scenarios: []
)}