AshAuthentication.Errors.AuthenticationFailed does not implement the AshPhoenix.FormData.Error protocol

Thanks for you reply @FlyingNoodle !

I’ve done the refactors you adviced, the test still passes (and my code is improved), but I still have the warning that AshAuthentication errors are not handled by AshPheonix.FormData.Error.

Here is my full current liveview:

defmodule PrepairWeb.UserUpdatePasswordLive do
  use PrepairWeb, :live_view
  use Gettext, backend: PrepairWeb.Gettext

  alias Prepair.AshDomains.Accounts

  def render(assigns) do
    ~H"""
    <div class="mx-auto max-w-sm">
      <.header class="text-center">
        <%= gettext("Update your password") %>

        <:actions>
          <.link patch={~p"/"}>
            <.button><%= gettext("Go Back Home") %></.button>
          </.link>
        </:actions>
      </.header>

      <.simple_form
        for={@update_password_form}
        id="update_password_form"
        phx-submit="save"
        phx-change="validate"
      >
        <.error :if={@check_errors}>
          <%= gettext("Oops, something went wrong! Please check the errors below.") %>
        </.error>

        <.input
          field={@update_password_form[:email]}
          type="hidden"
          id="hidden_user_email"
          value={@current_email}
        />

        <.input
          field={@update_password_form[:current_password]}
          type="password"
          label={gettext("Current password")}
          required
        />

        <.input
          field={@update_password_form[:password]}
          type="password"
          label={gettext("New password")}
          required
        />

        <.input
          field={@update_password_form[:password_confirmation]}
          type="password"
          label={gettext("New password confirmation")}
          required
        />

        <:actions>
          <.button phx-disable-with={gettext("Updating password...")} class="w-full">
            <%= gettext("Update password") %>
          </.button>
        </:actions>
      </.simple_form>
    </div>
    """
  end

  def mount(_params, _session, socket) do
    current_user = socket.assigns.current_user

    form =
      AshPhoenix.Form.for_update(current_user, :change_password,
        domain: Accounts,
        as: "user"
      )

    socket =
      socket
      |> assign(check_errors: false)
      |> assign(:current_email, current_user.email)
      |> assign(:update_password_form, to_form(form))

    {:ok, socket}
  end

  def handle_event("save", %{"user" => params}, socket) do
    current_user = socket.assigns.current_user
    form = socket.assigns.update_password_form

    case AshPhoenix.Form.submit(form,
           params: params,
           actor: current_user
         ) do
      {:ok, _user} ->
        {:noreply,
         socket
         |> put_flash(:info, "Password updated successfully")
         |> redirect(to: ~p"/")}

      {:error, form} ->
        {:noreply,
         socket
         |> assign(:update_password_form, to_form(form))
         |> assign(check_errors: true)}
    end
  end

  # TODO: transform to a modal from the current profile page
  def handle_event("validate", %{"user" => params}, socket) do
    current_user = socket.assigns.current_user

    form =
      AshPhoenix.Form.for_update(current_user, :change_password,
        domain: Accounts,
        as: "user"
      )
      |> AshPhoenix.Form.validate(params)

    {:noreply, assign(socket, :update_password_form, to_form(form))}
  end
end