Skip to content

Commit

Permalink
fix: include tenant when checking identity conflicts
Browse files Browse the repository at this point in the history
fixes #850
  • Loading branch information
zachdaniel committed Dec 3, 2024
1 parent d8adc1a commit 9ad86b8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,23 @@ defmodule AshAuthentication.AddOn.Confirmation.ConfirmationHookChange do
Enum.any?(filter, fn {_k, v} -> is_nil(v) end)

if (identity.nils_distinct? && has_nil?) ||
!exists?(changeset.resource, filter) do
!exists?(changeset, filter) do
{:cont, changeset}
else
{:halt, {:error, identity}}
end
end)
end

defp exists?(resource, filter) do
resource
defp exists?(changeset, filter) do
changeset.resource
|> Query.do_filter(filter)
|> Query.set_context(%{
private: %{
ash_authentication?: true
}
})
|> Ash.exists?()
|> Ash.exists?(tenant: changeset.tenant)
end

defp maybe_perform_confirmation(%Changeset{} = changeset, strategy, original_changeset) do
Expand Down

0 comments on commit 9ad86b8

Please sign in to comment.