diff --git a/lib/ash_authentication/strategies/magic_link/request_preparation.ex b/lib/ash_authentication/strategies/magic_link/request_preparation.ex index 61c6167..0313089 100644 --- a/lib/ash_authentication/strategies/magic_link/request_preparation.ex +++ b/lib/ash_authentication/strategies/magic_link/request_preparation.ex @@ -26,8 +26,11 @@ defmodule AshAuthentication.Strategy.MagicLink.RequestPreparation do identity = Query.get_argument(query, identity_field) select_for_senders = Info.authentication_select_for_senders!(query.resource) - query - |> Query.filter(^ref(identity_field) == ^identity) + if is_nil(identity) do + Query.filter(query, false) + else + Query.filter(query, ^ref(identity_field) == ^identity) + end |> Query.before_action(fn query -> Ash.Query.ensure_selected(query, select_for_senders) end) diff --git a/lib/ash_authentication/strategies/password/request_password_reset_preparation.ex b/lib/ash_authentication/strategies/password/request_password_reset_preparation.ex index 14b1068..69cf08f 100644 --- a/lib/ash_authentication/strategies/password/request_password_reset_preparation.ex +++ b/lib/ash_authentication/strategies/password/request_password_reset_preparation.ex @@ -27,8 +27,11 @@ defmodule AshAuthentication.Strategy.Password.RequestPasswordResetPreparation do identity = Query.get_argument(query, identity_field) select_for_senders = Info.authentication_select_for_senders!(query.resource) - query - |> Query.filter(^ref(identity_field) == ^identity) + if is_nil(identity) do + Query.filter(query, false) + else + Query.filter(query, ^ref(identity_field) == ^identity) + end |> Query.before_action(fn query -> Ash.Query.ensure_selected(query, select_for_senders) end)