Skip to content

Commit

Permalink
fix(igniter.add_strategy): Generated password reset action names did …
Browse files Browse the repository at this point in the history
…not match the defaults. (#834)
  • Loading branch information
jimsynz authored Nov 12, 2024
1 parent da2608b commit 2acb1a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
28 changes: 16 additions & 12 deletions lib/mix/tasks/ash_authentication.add_strategy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,25 @@ defmodule Mix.Tasks.AshAuthentication.AddStrategy do
defp generate_reset(igniter, sender, options) do
igniter
|> create_reset_sender(sender, options)
|> Ash.Resource.Igniter.add_new_action(options[:user], :request_password_reset, """
action :request_password_reset do
description "Send password reset instructions to a user if they exist."
|> Ash.Resource.Igniter.add_new_action(
options[:user],
:request_password_reset_with_password,
"""
action :request_password_reset_with_password do
description "Send password reset instructions to a user if they exist."
argument :#{options[:identity_field]}, :ci_string do
allow_nil? false
end
argument :#{options[:identity_field]}, :ci_string do
allow_nil? false
end
# creates a reset token and invokes the relevant senders
run {AshAuthentication.Strategy.Password.RequestPasswordReset, action: :get_by_#{options[:identity_field]}}
end
""")
# creates a reset token and invokes the relevant senders
run {AshAuthentication.Strategy.Password.RequestPasswordReset, action: :get_by_#{options[:identity_field]}}
end
"""
)
|> ensure_get_by_action(options)
|> Ash.Resource.Igniter.add_new_action(options[:user], :reset_password, """
update :reset_password do
|> Ash.Resource.Igniter.add_new_action(options[:user], :password_reset_with_password, """
update :password_reset_with_password do
argument :reset_token, :string do
allow_nil? false
sensitive? true
Expand Down
4 changes: 2 additions & 2 deletions test/mix/tasks/ash_authentication.add_strategy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ defmodule Mix.Tasks.AshAuthentication.AddStrategyTest do
+ | end
+ | end
+ |
+ | action :request_password_reset do
+ | action :request_password_reset_with_password do
+ | description("Send password reset instructions to a user if they exist.")
+ |
+ | argument :email, :ci_string do
Expand All @@ -169,7 +169,7 @@ defmodule Mix.Tasks.AshAuthentication.AddStrategyTest do
+ | filter(expr(email == ^arg(:email)))
+ | end
+ |
+ | update :reset_password do
+ | update :password_reset_with_password do
+ | argument :reset_token, :string do
+ | allow_nil?(false)
+ | sensitive?(true)
Expand Down

0 comments on commit 2acb1a1

Please sign in to comment.