chore: add false filter on nil identity_field (#767)

This commit is contained in:
Zach Daniel 2024-08-11 20:19:16 -04:00 committed by GitHub
parent ccd0eb00d9
commit 151240df32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,8 +25,15 @@ defmodule AshAuthentication.Strategy.Password.SignInPreparation do
identity_field = strategy.identity_field
identity = Query.get_argument(query, identity_field)
query =
if is_nil(identity) do
# This will fail due to the argument being `nil`, so this is just a formality
Query.filter(query, false)
else
Query.filter(query, ^ref(identity_field) == ^identity)
end
query
|> Query.filter(^ref(identity_field) == ^identity)
|> check_sign_in_token_configuration(strategy)
|> Query.before_action(fn query ->
Ash.Query.ensure_selected(query, [strategy.hashed_password_field])