Skip to content

Commit

Permalink
fix: move change_password action to password strategy setup
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Dec 31, 2024
1 parent dc842af commit a6b8c3d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/mix/tasks/ash_authentication.add_strategy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,6 @@ if Code.ensure_loaded?(Igniter) do
run AshAuthentication.Strategy.MagicLink.Request
end
""")
|> Ash.Resource.Igniter.add_new_action(options[:user], :change_password, """
update :change_password do
# Use this action to allow users to change their password by providing
# their current password and a new password.
accept []
argument :current_password, :string, sensitive?: true, allow_nil?: false
argument :password, :string, sensitive?: true, allow_nil?: false
argument :password_confirmation, :string, sensitive?: true, allow_nil?: false
validate confirm(:password, :password_confirmation)
validate {AshAuthentication.Strategy.Password.PasswordValidation, strategy_name: :password, password_argument: :current_password}
change {AshAuthentication.Strategy.Password.HashPasswordChange, strategy_name: :password}
end
""")
|> AshAuthentication.Igniter.add_new_strategy(options[:user], :magic_link, :magic_link, """
magic_link do
identity_field :#{options[:identity_field]}
Expand Down Expand Up @@ -221,6 +205,22 @@ if Code.ensure_loaded?(Igniter) do
end
end
""")
|> Ash.Resource.Igniter.add_new_action(options[:user], :change_password, """
update :change_password do
# Use this action to allow users to change their password by providing
# their current password and a new password.
accept []
argument :current_password, :string, sensitive?: true, allow_nil?: false
argument :password, :string, sensitive?: true, allow_nil?: false
argument :password_confirmation, :string, sensitive?: true, allow_nil?: false
validate confirm(:password, :password_confirmation)
validate {AshAuthentication.Strategy.Password.PasswordValidation, strategy_name: :password, password_argument: :current_password}
change {AshAuthentication.Strategy.Password.HashPasswordChange, strategy_name: :password}
end
""")
|> generate_sign_in_and_registration(options)
|> generate_reset(sender, options)
|> add_confirmation(options)
Expand Down

0 comments on commit a6b8c3d

Please sign in to comment.