feat: require login

This commit is contained in:
Moritz Böhme 2025-04-06 18:17:37 +02:00
parent 26b33060ee
commit 22fb157d5c
3 changed files with 6 additions and 21 deletions

View file

@ -14,7 +14,7 @@ defmodule PutzplanWeb.AuthOverrides do
# set :text_class, "bg-red-500"
# end
# override AshAuthentication.Phoenix.Components.SignIn do
# set :show_banner, false
# end
override AshAuthentication.Phoenix.Components.SignIn do
set :show_banner, false
end
end

View file

@ -1,6 +1,5 @@
defmodule PutzplanWeb.TaskLive.Show do
use PutzplanWeb, :live_view
on_mount {PutzplanWeb.LiveUserAuth, :live_user_required}
@impl true
def render(assigns) do

View file

@ -24,7 +24,6 @@ defmodule PutzplanWeb.Router do
scope "/", PutzplanWeb do
pipe_through :browser
get "/", PageController, :home
auth_routes AuthController, Putzplan.Accounts.User, path: "/auth"
sign_out_route AuthController
@ -37,31 +36,18 @@ defmodule PutzplanWeb.Router do
AshAuthentication.Phoenix.Overrides.Default
]
ash_authentication_live_session :authenticated_routes do
ash_authentication_live_session :authentication_required,
on_mount: {PutzplanWeb.LiveUserAuth, :live_user_required} do
live "/", TaskLive.Index, :index
live "/tasks", TaskLive.Index, :index
live "/tasks/new", TaskLive.Index, :new
live "/tasks/:id/edit", TaskLive.Index, :edit
live "/tasks/:id", TaskLive.Show, :show
live "/tasks/:id/show/edit", TaskLive.Show, :edit
# in each liveview, add one of the following at the top of the module:
#
# If an authenticated user must be present:
# on_mount {PutzplanWeb.LiveUserAuth, :live_user_required}
#
# If an authenticated user *may* be present:
# on_mount {PutzplanWeb.LiveUserAuth, :live_user_optional}
#
# If an authenticated user must *not* be present:
# on_mount {PutzplanWeb.LiveUserAuth, :live_no_user}
end
end
# Other scopes may use custom stacks.
# scope "/api", PutzplanWeb do
# pipe_through :api
# end
# Enable LiveDashboard and Swoosh mailbox preview in development
if Application.compile_env(:putzplan, :dev_routes) do
# If you want to use the LiveDashboard in production, you should put