I'm trying to make sonata work like this:
- if a regular user logs in he's redirected to "/"
- if an admin logs in he's redirected to "/admin/dashboard"
I tried to make it with firewalls that are in app/config/security.yml and here's what i come to:
# This firewall is used to handle the admin login area
# This part is handled by the Sonata User Bundle
admin:
pattern: /(.*)
context: user
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /login_check
failure_path: null
default_target_path: /admin/dashboard
logout:
path: /admin/logout
target: /
anonymous: true
# This firewall is used to handle the public login area
# This part is handled by the FOS User Bundle
main:
pattern: .*
context: user
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /login_check
failure_path: null
default_target_path: /
always_use_default_target_path: true
logout:
path: /logout
target: /
now every logged in user is redirected to /admin obviously throwing 'access denied' for non-admin users. Is there any way to fix it in this yml file or shall i search for some different way of checking user roles?