Add the session handler as a global twig variable, check for user session details in the skeleton
This commit is contained in:
parent
e7aabff62c
commit
a1c3bea6e5
@ -48,6 +48,7 @@ class Middlewares
|
||||
|
||||
$flash = $container->get(SessionInterface::class)->getFlash();
|
||||
$twig->getEnvironment()->addGlobal('flash', $flash);
|
||||
$twig->getEnvironment()->addGlobal('session', $container->get(SessionInterface::class));
|
||||
|
||||
$app->add(TwigMiddleware::create($app, $twig));
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<nav>
|
||||
<ul>
|
||||
{% if user.authenticated %}
|
||||
{% if session.get('user').authenticated %}
|
||||
<li><a href="/dashboard">Dashboard</a></li>
|
||||
<li><a href="/logout">Logout</a></li>
|
||||
{% else %}
|
||||
|
@ -1,4 +1,3 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
cli:
|
||||
user: "1000:1000"
|
||||
|
@ -1,4 +1,3 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
php:
|
||||
build:
|
||||
|
Loading…
Reference in New Issue
Block a user