Login Flow
Log in with one of the demo accounts to reach the dashboard and profile pages, then log out. Those two routes sit in a Via::group() behind a PSR-15 AuthMiddleware; the login form is public.
/examples/login is public. Dashboard and profile are protected via Via::group()->middleware(new AuthMiddleware(...)): one call shields both.via.session attribute, looks up sessionData('auth') in the server-side session store, and either redirects (302) or passes the auth record downstream as a request attribute. It runs again when a tab that was away comes back.$c->getRequestAttribute('auth'): the middleware-set attribute is automatically bridged from the PSR-7 request to the Via Context. No manual session checks needed.$c->regenerateSession(), so a cookie someone planted or read before stops reaching the account 10 seconds later. Logout also clears sessionData('auth'), and the middleware blocks protected pages until the next login.Demo credentials
| Username | Password | Role |
|---|---|---|
ada |
lovelace |
Engineer |
grace |
hopper |
Admiral |
linus |
torvalds |
Maintainer |
Try visiting /examples/login/dashboard directly:
the AuthMiddleware will redirect you back here because you're not logged in yet.
After logging in, you'll be sent to the protected dashboard automatically.
Signals
username
string tab scope initial: empty string Username input bound to the login form.
password
string tab scope initial: empty string Password input. Cleared on failure.
error
string tab scope initial: empty string Validation error message shown beneath the form.
Actions
login
Validates credentials. On success, rotates the session cookie, writes auth to sessionData and redirects to the middleware-protected dashboard.
Views
login.html.twig
Login form. Redirects to dashboard if already authenticated.
login_dashboard.html.twig
Protected dashboard. Auth data injected by AuthMiddleware via request attributes.
login_profile.html.twig
Protected profile page. Same AuthMiddleware protects it via the shared group.
Middleware
AuthMiddleware
PSR-15 middleware that checks sessionData('auth') and redirects unauthenticated requests to the login form. As route middleware it runs on page loads and when a tab that was away comes back, not on actions or SSE connects: a dashboard tab left open at logout keeps its stream until it reloads.