From 693a41f95e889c44da6cad14c573e0948ae354de Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Fri, 22 Sep 2023 12:13:16 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20handle=20change=20from=20ash=5Fauthentic?= =?UTF-8?q?ation=20where=20resettable=20is=20no=20lon=E2=80=A6=20(#279)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .tool-versions | 4 ++-- .../components/password.ex | 13 +++++++------ .../components/password/input.ex | 9 ++++++--- .../components/password/reset_form.ex | 2 +- .../components/reset/form.ex | 4 ++-- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.tool-versions b/.tool-versions index 49b752f..44acbf0 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -erlang 25.2 -elixir 1.14.2 +erlang 26.0.2 +elixir 1.15.4 diff --git a/lib/ash_authentication_phoenix/components/password.ex b/lib/ash_authentication_phoenix/components/password.ex index 95c93f8..b4e2867 100644 --- a/lib/ash_authentication_phoenix/components/password.ex +++ b/lib/ash_authentication_phoenix/components/password.ex @@ -107,14 +107,15 @@ defmodule AshAuthentication.Phoenix.Components.Password do strategy.registration_enabled? && override_for(assigns.overrides, :register_toggle_text) reset_enabled? = - Enum.any?(strategy.resettable) && override_for(assigns.overrides, :reset_toggle_text) + strategy.resettable && override_for(assigns.overrides, :reset_toggle_text) reset_id = - strategy.resettable - |> Enum.map( - &generate_id(subject_name, strategy_name, &1.request_password_reset_action_name) - ) - |> List.first() + strategy.resettable && + generate_id( + subject_name, + strategy_name, + strategy.resettable.request_password_reset_action_name + ) assigns = assigns diff --git a/lib/ash_authentication_phoenix/components/password/input.ex b/lib/ash_authentication_phoenix/components/password/input.ex index 0a0b5d7..16f196e 100644 --- a/lib/ash_authentication_phoenix/components/password/input.ex +++ b/lib/ash_authentication_phoenix/components/password/input.ex @@ -225,8 +225,8 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do case assigns.action do :request_reset -> assigns.strategy.resettable - |> Enum.map(& &1.request_password_reset_action_name) - |> List.first(:request_reset) + |> Kernel.||(%{}) + |> Map.get(:request_password_reset_action_name, :reset_request) |> to_string() |> String.trim_trailing("_with_password") @@ -248,7 +248,10 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do |> assign_new(:disable_text, fn -> nil end) ~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 diff --git a/lib/ash_authentication_phoenix/components/password/reset_form.ex b/lib/ash_authentication_phoenix/components/password/reset_form.ex index 55a1e8c..3643dc9 100644 --- a/lib/ash_authentication_phoenix/components/password/reset_form.ex +++ b/lib/ash_authentication_phoenix/components/password/reset_form.ex @@ -162,7 +162,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.ResetForm do Map.get(params, param_key, %{}) 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) subject_name = Info.authentication_subject_name!(strategy.resource) diff --git a/lib/ash_authentication_phoenix/components/reset/form.ex b/lib/ash_authentication_phoenix/components/reset/form.ex index d8c3f3a..cbe3596 100644 --- a/lib/ash_authentication_phoenix/components/reset/form.ex +++ b/lib/ash_authentication_phoenix/components/reset/form.ex @@ -58,11 +58,11 @@ defmodule AshAuthentication.Phoenix.Components.Reset.Form do api = Info.authentication_api!(strategy.resource) subject_name = Info.authentication_subject_name!(strategy.resource) - [resettable] = strategy.resettable + resettable = strategy.resettable form = strategy.resource - |> Form.for_action(resettable.password_reset_action_name, + |> Form.for_action(strategy.resettable.password_reset_action_name, api: api, as: subject_name |> to_string(), id: