I'm not new to symfony, but I always used FOSUserBundle , which by default forbids one of two different login forms to authenticate two different types of users.
I have two entities, one is Admins and the other is Users . Administrators can only register in the administration area, and users can only log in through the interface.
I followed http://symfony.com/doc/2.1/book/security.html , which also led me to http://symfony.com/doc/2.1/cookbook/security/entity_provider.html
My security.yml:
jms_security_extra: secure_all_services: false expressions: true security: encoders: Symfony\Component\Security\Core\User\User: sha512 Fm\AdminBundle\Entity\Admins: sha512 Fm\MainBundle\Entity\Users: sha512 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: chain_provider: chain: providers: [in_memory, admin] in_memory: memory: users: user: { password: userpass, roles: [ 'ROLE_USER' ] } admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] } admin: entity: { class: Fm\AdminBundle\Entity\Admins, property: username } firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false anonymous: true alogin: pattern: ^/admin/login security: false login: pattern: ^/login security: false secured_area: pattern: ^/admin anonymous: false provider: chain_provider switch_user: true form_login: check_path: /admin/login_check login_path: /admin/login logout: path: /admin/logout target: /admin members_area: pattern: ^/ anonymous: false form_login: ~ logout: path: /logout target: /
In my routes, I defined the routes as in the docs: (by default for / admin / login and / admin / login_check due to my main include routing where / admin is installed)
_admin_login: pattern: /login defaults: { _controller: FmAdminBundle:Security:login } _admin_login_check: pattern: /login_check
The error I get in the browser:
Unable to find the controller for path "/admin/login_check". Maybe you forgot to add the matching route in your routing configuration?
The stack trace tells me: WARNING - Unable to look for the controller as the "_controller" parameter is missing
AND
ERROR - Symfony\Component\HttpKernel\Exception\NotFoundHttpException: Unable to find the controller for path "/admin/login_check". Maybe you forgot to add the matching route in your routing configuration? (uncaught exception) at /var/www/mysite.dev/symfony/app/bootstrap.php.cache line 1419
source share