how to make the onAuthenticationSuccess function being called
<p>I would like to have some action after a success authentification.</p>

<p>I created a class extended DefaultAuthenticationSuccessHandler, and redefined the onAuthenticationSuccess function.</p>

<p>Though the authentication is a success, the programm never goes to the function : why ?</p>

<hr>

<pre><code>namespace my_name_space;

use   Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Bridge\Monolog\Logger;


class AuthenticationSuccessHandler extends DefaultAuthenticationSuccessHandler {
private $em;
private $logger;

function __construct(Logger $logger, HttpUtils $httpUtils, EntityManager $em) {
    parent::__construct($httpUtils);
    $this-&gt;em = $em;
    $this-&gt;logger = $logger;
}

public function onAuthenticationSuccess(Request $request, TokenInterface $token) {
    $this-&gt;logger-&gt;info("onAuthenticationSuccess");
    $response = parent::onAuthenticationSuccess($request, $token);
    $token-&gt;eraseCredentials();        
    $token-&gt;getUser()-&gt;addRole('ROLE_USER');

    return $response;
}
</code></pre>

<p>}</p>

<pre><code>services:
security.authentication.success.handler:
    class: MY\NAMESPACE\AuthenticationSuccessHandler
    arguments: ["@monolog.logger.php","@security.http_utils", "@doctrine.orm.default_entity_manager"]
</code></pre>

<p>security.yml</p>

<pre><code>form_login:
            check_path: _security_check
            use_referer: true
            use_forward: true
            login_path: my_login
            success_handler: security.authentication.success.handler
</code></pre>