Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I listen for “remember me” reauthentication events in Symfony2?

Using “normal” — not “remember me” authentication — I can set a success and failure handlers, adding this to the security.yml file:

form_login:
    # ...
    success_handler: authentication_handler
    failure_handler: authentication_handler

But I couldn't find a way for listening for “remember me” reauthentication, when a user's session is expired and a “remember me” cookie is used to reauthenticate again. Any ideas on how can I achieve this?

like image 666
Elnur Abdurrakhimov Avatar asked Oct 09 '22 14:10

Elnur Abdurrakhimov


1 Answers

Create a Listener for the security.interactive_login event. That gets triggered on both simple and "remember me" logins (see Symfony\Component\Security\Http\Firewall\RememberMeListener.php @line:77).

In the listener you can separate the two by checking the cookie. You can find more about the listener here.

like image 105
nezuvian Avatar answered Oct 13 '22 10:10

nezuvian