1) FOSUserBundle registration redirects to confirmedAction bydefault
if (null === $response = $event->getResponse()) {
$url = $this->generateUrl('fos_user_registration_confirmed');
$response = new RedirectResponse($url);
}
$dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
return $response;
I want to override this behaviour as I am calling registerAction using REST. I want to return confirmation message instead of redirecting.
FilterUserResponseEvent do not allow to set response, there is no "setResponse" method.
2) FOSUserBundle's EmailConfirmationListener also redirects to checkEmail action
$url = $this->router->generate('fos_user_registration_check_email');
$event->setResponse(new RedirectResponse($url));
I want to override this behavious as well. I could do this by creating my EmailConfirmationListener service with same id "fos_user.listener.email_confirmation" and by doing this
$response = new Response($this->translator->trans('registration.check_email', array(
'%email%' => $user->getEmail()), 'FOSUserBundle'));
$event->setResponse($response);
But the problem is now below configuration is not working. It always sends confirmation email regardless of below configuration.
fos_user
registration
confirmation
enabled : false
I couldn't see any code in EmailConfirmationListerner which checks whether this configuration is enabled or not. Where is it checked, why overriding Listener stops configuration working ?