Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TokenStorage: setToken->(null) does not logout user with remember-me feature on #47156

Copy link
Copy link
Closed
@Jean-Gian

Description

@Jean-Gian
Issue body actions

Symfony version(s) affected

6.1

Description

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.