Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(igniter.add_strategy): Generated password reset action names did not match the defaults. #834

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading