0

when clickin on the link to confirm a registration, the new tab is open in the browser and a message about confirmation is shown. In the same time the user is also logged in. How to avoid this?

1
  • Which part do you want to not do? Commented Feb 1, 2015 at 0:21

1 Answer 1

2
  1. Override \FOS\UserBundle\Security\LoginManager class with your own. This login manager is used in the AuthenticationListener that's dispatched during the confirmation.

    fos_user.security.login_manager.class: namespace\YourUserBundle\Security\CustomLoginManager

Implementing the loginUser() method (e.g. return null) in your CustomLoginManager can disable auto login. However, do note that this disables auto login for the following events as well:

  • FOSUserEvents::REGISTRATION_COMPLETED
  • FOSUserEvents::REGISTRATION_CONFIRMED
  • FOSUserEvents::RESETTING_RESET_COMPLETED

(check - search - code when and where these are dispatched if this solution really suits your needs.)


  1. Override \FOSUserBundle:RegistrationController::confirmAction and DO NOT dispatch the appropriate event. (see documentation on how to override fosuser controllers)

Look for \FOS\UserBundle\FOSUserEvents::REGISTRATION_CONFIRMED) in the base controller's confirm action for reference.


  1. add a compiler pass to override/extend/implement your own AuthenticationListener that's being dispatched by the base fos user actions.

This is the most advanced, but leanest solution. See CompilerPassDocs on how to add one to your child bundle (the one extending fosuser). This is an example of the Compiler Pass file I propose:

class OverrideServiceCompilerPass implements CompilerPassInterface
{
     public function process(ContainerBuilder $container)
     {
          $definition = $container->getDefinition('fos_user.listener.authentication');
          $definition->setClass('namespace\MyUserBundle\EventListener\CustomAuthenticationListener');
     }
}

Look at the original \FOS\UserBundle\EventListener\AuthenticationListener file for reference, add the proper events and implement the method(s) accordingly in your custom auth listener. (e.g. return null on authenticate() perhaps.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.