fix: handle change from ash_authentication where resettable is no lon… (#279)

This commit is contained in:
Zach Daniel 2023-09-22 12:13:16 -04:00 committed by GitHub
parent 62bd241e4e
commit 693a41f95e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 14 deletions

View file

@ -1,2 +1,2 @@
erlang 25.2 erlang 26.0.2
elixir 1.14.2 elixir 1.15.4

View file

@ -107,14 +107,15 @@ defmodule AshAuthentication.Phoenix.Components.Password do
strategy.registration_enabled? && override_for(assigns.overrides, :register_toggle_text) strategy.registration_enabled? && override_for(assigns.overrides, :register_toggle_text)
reset_enabled? = reset_enabled? =
Enum.any?(strategy.resettable) && override_for(assigns.overrides, :reset_toggle_text) strategy.resettable && override_for(assigns.overrides, :reset_toggle_text)
reset_id = reset_id =
strategy.resettable strategy.resettable &&
|> Enum.map( generate_id(
&generate_id(subject_name, strategy_name, &1.request_password_reset_action_name) subject_name,
) strategy_name,
|> List.first() strategy.resettable.request_password_reset_action_name
)
assigns = assigns =
assigns assigns

View file

@ -225,8 +225,8 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
case assigns.action do case assigns.action do
:request_reset -> :request_reset ->
assigns.strategy.resettable assigns.strategy.resettable
|> Enum.map(& &1.request_password_reset_action_name) |> Kernel.||(%{})
|> List.first(:request_reset) |> Map.get(:request_password_reset_action_name, :reset_request)
|> to_string() |> to_string()
|> String.trim_trailing("_with_password") |> String.trim_trailing("_with_password")
@ -248,7 +248,10 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
|> assign_new(:disable_text, fn -> nil end) |> assign_new(:disable_text, fn -> nil end)
~H""" ~H"""
<%= submit(@label, class: override_for(@overrides, :submit_class), phx_disable_with: @disable_text) %> <%= submit(@label,
class: override_for(@overrides, :submit_class),
phx_disable_with: @disable_text
) %>
""" """
end end

View file

@ -162,7 +162,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.ResetForm do
Map.get(params, param_key, %{}) Map.get(params, param_key, %{})
end end
defp blank_form(%{resettable: [resettable]} = strategy) do defp blank_form(%{resettable: resettable} = strategy) when not is_nil(resettable) do
api = Info.authentication_api!(strategy.resource) api = Info.authentication_api!(strategy.resource)
subject_name = Info.authentication_subject_name!(strategy.resource) subject_name = Info.authentication_subject_name!(strategy.resource)

View file

@ -58,11 +58,11 @@ defmodule AshAuthentication.Phoenix.Components.Reset.Form do
api = Info.authentication_api!(strategy.resource) api = Info.authentication_api!(strategy.resource)
subject_name = Info.authentication_subject_name!(strategy.resource) subject_name = Info.authentication_subject_name!(strategy.resource)
[resettable] = strategy.resettable resettable = strategy.resettable
form = form =
strategy.resource strategy.resource
|> Form.for_action(resettable.password_reset_action_name, |> Form.for_action(strategy.resettable.password_reset_action_name,
api: api, api: api,
as: subject_name |> to_string(), as: subject_name |> to_string(),
id: id: