From ea12375b4fea95f635b528984d1aed8c800ac92b Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 13 Feb 2024 15:13:51 -0500 Subject: [PATCH] chore: fix `changing_attributes` filter check logic --- lib/ash/actions/destroy/bulk.ex | 2 +- lib/ash/actions/update/bulk.ex | 4 ++-- lib/ash/policy/check/changing_attributes.ex | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ash/actions/destroy/bulk.ex b/lib/ash/actions/destroy/bulk.ex index 4aeb3f6c..0eefd693 100644 --- a/lib/ash/actions/destroy/bulk.ex +++ b/lib/ash/actions/destroy/bulk.ex @@ -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, diff --git a/lib/ash/actions/update/bulk.ex b/lib/ash/actions/update/bulk.ex index 22d0fac2..09e1b4d7 100644 --- a/lib/ash/actions/update/bulk.ex +++ b/lib/ash/actions/update/bulk.ex @@ -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, diff --git a/lib/ash/policy/check/changing_attributes.ex b/lib/ash/policy/check/changing_attributes.ex index a4c1a5c5..01f4c409 100644 --- a/lib/ash/policy/check/changing_attributes.ex +++ b/lib/ash/policy/check/changing_attributes.ex @@ -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}