I’ve got FOSUserBundle installed and is working to an extent.. It logs me in, it does everything its supposed to — except redirect me to the right place..
I have my routes for it setup in my AdminBundle routes.yml file (the very routes from the FOSUserBundle installation documentation on github)
I’ve created a firewall for it:
security:
encoders:
"FOS\UserBundle\Model\UserInterface": sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
fos_userbundle:
id: fos_user.user_manager
firewalls:
admin_area:
pattern: ^/admin/
form_login:
check_path: /admin/login_check
login_path: /admin/login
provider: fos_userbundle
anonymous: true
logout:
path: /admin/logout
target: /admin/
access_control:
- { path: ^/admin/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, roles: ROLE_ADMIN }
The only problem is, when i go to http://mysite.dev/admin it redirects me to http://mysite.dev/admin/login which is correct… So I then login and it redirects me to http://mysite.dev/ instead of /admin
It’s important to note that I’ve extended the login form to make it look like my own.. by creating in the views folder for my AdminBundle a layout.html.twig to give it a look like the rest of the design for the admin that i’ll be using..
Any ideas? Thanks..
You need to place a hidden input named “_target_path” on your log in form, this is used by symfony to check where the user should be redirected after he or she has been successfully authenticated. You can customize it. Check the documentation at: http://symfony.com/doc/current/cookbook/security/form_login.html