Open darkopetreski opened 1 year ago
For now I have solved the problem by the following code:
use Lexik\Bundle\JWTAuthenticationBundle\Security\Http\Authentication\AuthenticationSuccessHandler;
#[Route('/autologin', methods: ['GET'])]
public function autologin(AuthenticationSuccessHandler $authenticationSuccessHandler): Response
{
$user = ....
return $authenticationSuccessHandler->handleAuthenticationSuccess($user);
}
Had the same. @darkopetreski approach works for me too and is even described in bundle's documentation:
public function fooAction(UserInterface $user)
{
$authenticationSuccessHandler = $this->container->get('lexik_jwt_authentication.handler.authentication_success');
return $authenticationSuccessHandler->handleAuthenticationSuccess($user);
}
Hope login programmatically will work with $security->login($user);
as well one day.
Thanks for the issue. https://github.com/symfony/symfony/pull/57495 will help
As described in the official documentation https://symfony.com/doc/current/security.html#login-programmatically I am trying to login a user automatically as suggested in the official documentation for Symfony 6.2:
But I get the following error:
I am using this bundle with cookie token extractor. The login method was introduced in 6.2 so maybe this bundle is not compatible with this method or more setup is needed ?