Examples menu

๐Ÿ” Login Flow

PSR-15 middleware-based authentication. The login form is public; the dashboard route is protected by an AuthMiddleware that checks sessionData('auth') and redirects unauthenticated users back here.

Two routes, one middleware. /examples/login is public. /examples/login/dashboard is protected by AuthMiddleware โ€” a real PSR-15 middleware attached via ->middleware().
AuthMiddleware reads the session cookie from the PSR-7 request, looks up sessionData('auth') in the server-side session store, and either redirects (302) or passes the auth record downstream as a request attribute.
The dashboard reads $c->getRequestAttribute('auth') โ€” the middleware-set attribute is automatically bridged from the PSR-7 request to the Via Context. No manual session checks needed in the page handler.
Logout clears the session and redirects back to the login form. The middleware will block any subsequent dashboard access until login succeeds again.

โšก Signals

username string TAB ""

Username input bound to the login form.

password string TAB ""

Password input. Cleared on failure.

error string TAB ""

Validation error message shown beneath the form.

๐ŸŽฏ Actions

login

Validates credentials. On success, 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.

๐Ÿ›ก๏ธ Middleware

AuthMiddleware

PSR-15 middleware that checks sessionData('auth') and redirects unauthenticated requests to the login form. Implements SseAwareMiddleware to also protect SSE connections.