feat(server): router pipelines + live_auth hook for authenticated dashboard

This commit is contained in:
Carsten 2026-04-21 22:51:41 +02:00
parent 4538945b85
commit 62996d883d
2 changed files with 34 additions and 7 deletions

View file

@ -0,0 +1,14 @@
defmodule ServerWeb.LiveAuth do
@moduledoc "on_mount hook for LiveView sessions requiring authentication."
import Phoenix.LiveView
import Phoenix.Component, only: [assign: 3]
def on_mount(:require_authenticated, _params, session, socket) do
if session["authenticated"] do
{:cont, assign(socket, :authenticated, true)}
else
{:halt, redirect(socket, to: "/login")}
end
end
end