How to definitely disable registration in FOSUserBundle

后端 未结 7 2414
无人及你
无人及你 2021-02-19 03:02

In my project, I allow only one user to manage the content of the website. This user will be added using the command line at first.

Now, I want to get the registration a

7条回答
  •  借酒劲吻你
    2021-02-19 03:28

    Another simple solution (the one I used) is to overwrite the registerAction() default FOSUserBundle controller method:

    namespace Acme\UserBundle\Controller;
    
    use FOS\UserBundle\Controller\RegistrationController as FOSRegistrationController;
    use Symfony\Component\HttpFoundation\Request;
    
    class RegistrationController extends FOSRegistrationController
    {
        public function registerAction(Request $request)
        {
            return $this->redirectToRoute('getStarted', array(), 301);
        }
    }
    

    Doing this will leave active other routes, as the confirmation page.

    I simply overwrote the register action and redirect the user to my first registration page (getStarted).

提交回复
热议问题