How can i force logout user logged from controle on the new Symfony 6 ? (Version 6.0.1)
I tried $tokenStorage->setToken($token); but setToken() need 2 args:
(public function setToken(string $tokenId, string $token);)
I tried $request->getSession()->invalidate();
but my user is always logged...
I want to logout the user and redirect to another route (à don't want redirect to logout route)
Thank you
CodePudding user response:
just redirect to the logout route:
return $this->redirect($this->generateUrl('YourLogoutRouteName'));
CodePudding user response:
@JeroenvanderLaan TokenStorageInterface needs 2 args :
namespace Symfony\Component\Security\Csrf\TokenStorage;
(...)
/**
* Reads a stored CSRF token.
*
* @throws \Symfony\Component\Security\Csrf\Exception\TokenNotFoundException If the token ID does not exist
*/
public function getToken(string $tokenId): string;
/**
* Stores a CSRF token.
*/
public function setToken(string $tokenId, string $token);
(...)
@Bossman
$id = $tokenStorage->getToken()->getId();
doesn't work aswell but i don't know what is the arg $tokenId needed to logout :/