diff --git a/lib/mix/tasks/ash_authentication.add_strategy.ex b/lib/mix/tasks/ash_authentication.add_strategy.ex index 757f8904..3e044853 100644 --- a/lib/mix/tasks/ash_authentication.add_strategy.ex +++ b/lib/mix/tasks/ash_authentication.add_strategy.ex @@ -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 diff --git a/test/mix/tasks/ash_authentication.add_strategy_test.exs b/test/mix/tasks/ash_authentication.add_strategy_test.exs index 78ee5f17..733fdf96 100644 --- a/test/mix/tasks/ash_authentication.add_strategy_test.exs +++ b/test/mix/tasks/ash_authentication.add_strategy_test.exs @@ -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 @@ -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)