chore: don't use opts[:resource] in relates to actor via check

This commit is contained in:
Zach Daniel 2024-09-16 10:17:40 -04:00
parent 4b749c4d1b
commit 8275c5c635
2 changed files with 4 additions and 4 deletions

View file

@ -9,10 +9,10 @@ defmodule Ash.Policy.Check.RelatesToActorVia do
end
@impl true
def filter(_actor, _context, opts) do
def filter(_actor, context, opts) do
opts = Keyword.update!(opts, :relationship_path, &List.wrap/1)
actor_field = Keyword.get(opts, :field)
{last_relationship, to_many?} = relationship_info(opts[:resource], opts[:relationship_path])
{last_relationship, to_many?} = relationship_info(context.resource, opts[:relationship_path])
pkey =
last_relationship.destination
@ -44,7 +44,7 @@ defmodule Ash.Policy.Check.RelatesToActorVia do
@impl true
def reject(actor, context, opts) do
opts = Keyword.update!(opts, :relationship_path, &List.wrap/1)
{last_relationship, to_many?} = relationship_info(opts[:resource], opts[:relationship_path])
{last_relationship, to_many?} = relationship_info(context.resource, opts[:relationship_path])
pkey =
last_relationship.destination

View file

@ -350,7 +350,7 @@ defmodule Ash.Policy.FilterCheck do
_ -> nil
end
opts = Keyword.put_new(opts, :resource, authorizer.resource)
opts = Keyword.update(opts, :resource, authorizer.resource, &(&1 || authorizer.resource))
{:ok,
actor