Эх сурвалжийг харах

Déconnexion fonctionnelle

SPAETER NATHAN 4 жил өмнө
parent
commit
6f041854cf

+ 20 - 0
src/Controller/DisconnectController.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Annotation\Route;
+
+class DisconnectController extends AbstractController
+{
+    #[Route('/disconnect', name: 'disconnect')]
+    public function index(): Response
+    {
+        $session = $this->get('session');
+        $session->clear();
+        return $this->render('disconnect/index.html.twig', [
+            'controller_name' => 'DisconnectController',
+        ]);
+    }
+}

+ 8 - 0
templates/disconnect/index.html.twig

@@ -0,0 +1,8 @@
+{% extends 'base.html.twig' %}
+
+{% block title %}Hello DisconnectController!{% endblock %}
+
+{% block body %}
+<div>Vous êtes désormais déconnecté.</div>
+<a href="{{ path('index') }}">Retourner à l'accueil</a>
+{% endblock %}

+ 1 - 1
templates/profile/index.html.twig

@@ -3,6 +3,7 @@
 {% block title %}Profil de {{username}}{% endblock %}
 
 {% block body %}
+<a href="{{ path('disconnect') }}">Se déconnecter</a>
 <h1>{{ username }}</h1>
 <dl>
     <dt>Description :</dt>
@@ -13,7 +14,6 @@
         {% else %}
         <dd>Public</dd>
         {% endif %}
-    <dd>{{ isPrivate }}</dd>
 </dl>
 <h2>Messages :</h2>
 {# <ul>