chore: fix changing_attributes filter check logic

This commit is contained in:
Zach Daniel 2024-02-13 15:13:51 -05:00
parent 71cf111d4d
commit ea12375b4f
3 changed files with 5 additions and 5 deletions

View file

@ -785,7 +785,7 @@ defmodule Ash.Actions.Destroy.Bulk do
defp authorize_atomic_changeset(query, changeset, opts) do
if opts[:authorize?] do
case query.api.can(query, opts[:actor],
case query.api.can(changeset, opts[:actor],
return_forbidden_error?: true,
maybe_is: false,
alter_source?: true,

View file

@ -334,7 +334,7 @@ defmodule Ash.Actions.Update.Bulk do
with {:ok, query} <- authorize_bulk_query(query, opts),
{:ok, atomic_changeset, query} <-
authorize_changeset(query, atomic_changeset, opts),
authorize_atomic_changeset(query, atomic_changeset, opts),
{:ok, data_layer_query} <- Ash.Query.data_layer_query(query) do
case Ash.DataLayer.update_query(
data_layer_query,
@ -807,7 +807,7 @@ defmodule Ash.Actions.Update.Bulk do
end
end
defp authorize_changeset(query, changeset, opts) do
defp authorize_atomic_changeset(query, changeset, opts) do
if opts[:authorize?] do
case changeset.api.can(changeset, opts[:actor],
return_forbidden_error?: true,

View file

@ -45,10 +45,10 @@ defmodule Ash.Policy.Check.ChangingAttributes do
)
{{:ok, from}, :error} ->
Ash.Expr.expr(^expr and ref(attribute) != ^from)
{:cont, Ash.Expr.expr(^expr and ref(attribute) != ^from)}
{:error, {:ok, to}} ->
Ash.Expr.expr(^expr and ^atomic_ref(attribute) != ^to)
{:cont, Ash.Expr.expr(^expr and ^atomic_ref(attribute) != ^to)}
end
else
{:cont, expr}