Skip to content

Commit

Permalink
improvement: avoid warning about comparison with nil
Browse files Browse the repository at this point in the history
the previous implementation was not a security issue because the
actual action would not execute with a `nil` identity
  • Loading branch information
zachdaniel committed Aug 21, 2024
1 parent c4f5703 commit d9a2783
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d9a2783

Please sign in to comment.