mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: unset cookie when logout
This commit is contained in:
@@ -4,12 +4,19 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
|
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
|
|
||||||
class HomeController extends AbstractController
|
class HomeController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function __construct(private readonly RouterInterface $router)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[Route(path: "/", name: "index")]
|
#[Route(path: "/", name: "index")]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
@@ -21,4 +28,14 @@ class HomeController extends AbstractController
|
|||||||
{
|
{
|
||||||
return $clientRegistry->getClient('oauth')->redirect();
|
return $clientRegistry->getClient('oauth')->redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route(path: "/logout", name: "logout")]
|
||||||
|
public function logout(Security $security): ?RedirectResponse
|
||||||
|
{
|
||||||
|
$response = new RedirectResponse($this->router->generate('index'));
|
||||||
|
$response->headers->clearCookie('BEARER');
|
||||||
|
if ($security->isGranted('IS_AUTHENTICATED')) $security->logout(false);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Entity;
|
|||||||
use ApiPlatform\Metadata\ApiResource;
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use ApiPlatform\Metadata\Get;
|
use ApiPlatform\Metadata\Get;
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
use ApiPlatform\Metadata\Post;
|
|
||||||
use App\Controller\DomainRefreshController;
|
use App\Controller\DomainRefreshController;
|
||||||
use App\Repository\DomainRepository;
|
use App\Repository\DomainRepository;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
@@ -13,7 +12,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\DBAL\Types\Types;
|
use Doctrine\DBAL\Types\Types;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
use Symfony\Component\Serializer\Attribute\Groups;
|
||||||
use Symfony\Component\Serializer\Attribute\SerializedName;
|
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user