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

余生颓废 提交于 2019-12-05 09:37:21
nezuvian

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.

I haven't tried this but maybe you could attach listener to success_handler but make sure you inject SecurityContext service via <argument> in service config.

Then, is soon as you enter you service method you do:

if ( $this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') ){
    // I am remembered visitor
}else{
    // I am the new visitor
}

Again, this is just an idea but sounds like it could do...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!