'Symfony - Redirect on onSecurityAuthenticationSuccess

How can I return a response redirect in the onSecurityAuthenticationSuccess method?

public function onSecurityAuthenticationSuccess(AuthenticationEvent $event)
{
    $finalDestination= sprintf('%s?%s=false', $this->destination, self::PARAM_MATCH_SESSION);

    return new RedirectResponse($finalDestination);
}

In my code the redirect doesn't work. Thanks for your response.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source