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
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