FOSUserBundle icon indicating copy to clipboard operation
FOSUserBundle copied to clipboard

After clicking confirmation e-mail link user is automatically logged in but custom Authentication handler is not called

Open WojciechJasinski opened this issue 13 years ago • 6 comments

I have crated custom authentication handler that creates some extra sessions on authentication success. While using FOSUserBundle with email confirmation enabled this handler is not called when new user clicks confirmation link. My handler is configured in form_login:success_handler (security.yml). How can I add this to FOSUserBundle confirmation process as well?

WojciechJasinski avatar Nov 16 '12 14:11 WojciechJasinski

The same situation occurs after successfully resetting password.

WojciechJasinski avatar Nov 25 '12 15:11 WojciechJasinski

AFAIK the login after reset/confirmation is done by creating a security context object and storing it into the session. Because this is done outside the Symfonys2 normal authentication workflow none of those events get triggered.

mvrhov avatar Nov 26 '12 07:11 mvrhov

since #867 the process dispatches the FOS\UserBundle\FOSUserEvents::SECURITY_IMPLICIT_LOGIN event

stof avatar Dec 27 '12 22:12 stof

I encounter the same problem with registration. I have a handler adding cookies for doing a kind of SSO. How can I add cookies with the listener of the implicit login ? Modifying the response object in the middle of an event listener does not sounds right to me (And I didn't find how to do it).

OwlyCode avatar Jan 20 '13 22:01 OwlyCode

I am also wanting to modify the Response after login, and this is working ok with an AuthenticationHandler, but the handler is not called after reset/confirmation. I am listening to SECURITY_IMPLICIT_LOGIN but am unable to modify the Response from within the listener. How can I trigger the handler or modify the response? I see some events have $event->setResponse() but the events here do not.

bobemoe avatar Mar 14 '13 10:03 bobemoe

You can override confirmAction of FOSUserBundle and add this code to the end.

$token = $this->container->get('security.context')->getToken();
$response = $this->container->get('authentication_handler')->onAuthenticationSuccess($request, $token);

jur3 avatar Aug 29 '14 06:08 jur3