Ash FrameworkAF
Ash Framework7mo ago
16 replies
aidalgol

AshAuthentication confirmation page not using correct layout

The page served for /auth/user/confirm_new_user?confirm=longtokenhere does not appear to be using my application's layout template, because it does not have any of the elements in <head> that the rest of my app has.
My router looks like this:
defmodule MyAppWeb.Router do
  use MyAppWeb, :router
  use AshAuthentication.Phoenix.Router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_live_flash
    plug :put_root_layout, html: {MyAppWeb.Layouts, :root}
    plug :protect_from_forgery
    plug :put_app_browser_headers
    plug :load_from_session
  end

  scope "/", MyAppWeb do
    pipe_through :browser

    get "/", PageController, :home

    ash_authentication_live_session :authentication_required,
      on_mount_prepend:
        if(Application.compile_env(:my_app, :sandbox), do: MyAppWeb.LiveAllowEctoSandbox),
      on_mount: [{MyAppWeb.LiveUserAuth, :live_user_required}] do
      # ...
    end

    ash_authentication_live_session :authentication_optional,
      on_mount_prepend:
        if(Application.compile_env(:my_app, :sandbox), do: MyAppWeb.LiveAllowEctoSandbox),
      on_mount: [{MyAppWeb.LiveUserAuth, :live_user_optional}] do
      # ...
    end

    confirm_route MyApp.Accounts.User, :confirm_new_user, auth_routes_prefix: "/auth"
    auth_routes AuthController, MyApp.Accounts.User, path: "/auth"
    sign_out_route AuthController

    sign_in_route register_path: "/register",
                  reset_path: "/reset",
                  auth_routes_prefix: "/auth",
                  on_mount_prepend:
                    if(Application.compile_env(:my_app, :sandbox),
                      do: MyAppWeb.LiveAllowEctoSandbox
                    ),
                  on_mount: [{MyAppWeb.LiveUserAuth, :live_no_user}]

    reset_route auth_routes_prefix: "/auth"
  end

  # ...
end
Solution
If I explicitly pass path: "/auth/user/", then the root layout is used. I'm now thinking the URL I send in the email is incorrect.
Was this page helpful?