You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When i need to programmatically logout a user from a controller i use: setToken(null) from this interface Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
This logs a user out correctly only if the remember-me feature is not active and the REMEMBERME token is not set.
If a user is logged-in via the remember-me feature, logout doesn't happen.
I think this can be considered a bug, unless there are 2 different ways of logging out a user based on the type of login: regular or with remember-me. But in any case, there should be a single way to logout user regardless the type of login used.
How to reproduce
Something like this in a controller:
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class ReproduceBugController extends AbstractController
{
#[Route('/reproduce/bug', name: 'app_reproduce_bug')]
public function index(TokenStorageInterface $tokenStorage): Response
{
$tokenStorage->setToken(null);
return $this->redirectToRoute('app_reproduce_bug');
}
}
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Yes, programmatic logout is a bit more involving. That's not a bug.
We've just merged #41406 for that so please have a look to take what you need until it's released.
Symfony version(s) affected
6.1
Description
When i need to programmatically logout a user from a controller i use:
setToken(null)
from this interfaceSymfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
This logs a user out correctly only if the remember-me feature is not active and the REMEMBERME token is not set.
If a user is logged-in via the remember-me feature, logout doesn't happen.
I think this can be considered a bug, unless there are 2 different ways of logging out a user based on the type of login: regular or with remember-me. But in any case, there should be a single way to logout user regardless the type of login used.
How to reproduce
Something like this in a controller:
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: