8000 Method triggerRememberMe not called because of LazyResponseException · Issue #34761 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Method triggerRememberMe not called because of LazyResponseException #34761
Closed
@lukepass

Description

@lukepass

Symfony version(s) affected: 4.4.0

Description
I am developing a site using Symfony 4 and I noticed that remember me functionality is not working (the cookie is not set at all). I followed this tutorial:

https://symfony.com/doc/4.4/security/remember_me.html

Please see this post for all my configuration settings:

https://stackoverflow.com/questions/59086076/symfony-4-remember-me-cookie-not-set?noredirect=1#comment104435173_59086076

Essentially the remember me is not triggered at all:

// success!
$response = $this->guardHandler->handleAuthenticationSuccess($token, $request, $guardAuthenticator, $this->providerKey);
if ($response instanceof Response) {
    if (null !== $this->logger) {
        $this->logger->debug('Guard authenticator set success response.', ['response' => $response, 'authenticator' => \get_class($guardAuthenticator)]);
    }

    $event->setResponse($response); // <-- this is where the esecution STOPs
} else {
    if (null !== $this->logger) {
        $this->logger->debug('Guard authenticator set no success response: request continues.', ['authenticator' => \get_class($guardAuthenticator)]);
    }
}

// --> This line is NEVER CALLED
// attempt to trigger the remember me functionality
$this->triggerRememberMe($guardAuthenticator, $request, $token, $response);
// <-- This line is NEVER CALLED

Debugging into setResponse I saw that it's throwing a LazyResponseException and so the next line is never reached.

How to reproduce
Follow the remember me tutorial and set up a GuardAuthenticationListener.

Possible Solution
Maybe the triggerRememberMe should be called earlier?

Additional context
Please review the following StackOverflow post where you can find all the relevant classes and configurations:

https://stackoverflow.com/questions/59086076/symfony-4-remember-me-cookie-not-set?noredirect=1#comment104435173_59086076

Thanks.

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

      0