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();
|
$flash = $container->get(SessionInterface::class)->getFlash();
|
||||||
$twig->getEnvironment()->addGlobal('flash', $flash);
|
$twig->getEnvironment()->addGlobal('flash', $flash);
|
||||||
|
$twig->getEnvironment()->addGlobal('session', $container->get(SessionInterface::class));
|
||||||
|
|
||||||
$app->add(TwigMiddleware::create($app, $twig));
|
$app->add(TwigMiddleware::create($app, $twig));
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
{% if user.authenticated %}
|
{% if session.get('user').authenticated %}
|
||||||
<li><a href="/dashboard">Dashboard</a></li>
|
<li><a href="/dashboard">Dashboard</a></li>
|
||||||
<li><a href="/logout">Logout</a></li>
|
<li><a href="/logout">Logout</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
services:
|
services:
|
||||||
cli:
|
cli:
|
||||||
user: "1000:1000"
|
user: "1000:1000"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
services:
|
services:
|
||||||
php:
|
php:
|
||||||
build:
|
build:
|
||||||
|
Loading…
Reference in New Issue
Block a user