Ash FrameworkAF
Ash Framework3y ago
24 replies
samoorai

Custom Auth

Hello, I'm trying to get custom auth working but I don't know how to put the user inside the session after the login form submisison.
I created a custom live form with a phx-sumbit event called "save" the method looks like this:

  @impl true
  def handle_event("save", %{"merchant" => merchant_params}, socket) do
    case AshPhoenix.Form.submit(socket.assigns.form, params: merchant_params) do
      {:ok, merchant} ->
        Logger.error("Loggato con successo")
        {:noreply,
         socket
         |> assign(:current_merchant, merchant)
         |> put_flash(:success, "Loggato con successo")
         |> push_navigate(to: ~p"/")}

      {:error, form} ->
        {:noreply, assign(socket, form: form)}
    end
  end


I was trying to put the logged user inside the socket but I think I'm missing something.
Was this page helpful?