How to definitely disable registration in FOSUserBundle

Abdou Bestmood picture Abdou Bestmood · Jun 29, 2015 · Viewed 7.3k times · Source

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 action inaccessible and I don't know how? Till now, I just put the ROLE_ADMIN in the access control for the route register to avoid that visitors can go throw it.

Any tips?

Answer

Petr Malina picture Petr Malina · Oct 13, 2016

Take a look at the routing configuration imported from

vendor/friendsofsymfony/user-bundle/Resources/config/routing/all.xml

If you want just the basic security actions, just import

@FOSUserBundle/Resources/config/routing/security.xml

instead of

@FOSUserBundle/Resources/config/routing/all.xml

This way you can simply select which components (security, profile, resetting, change_password) you want to use or event import only specific routes from those components.