0

I've got a symfony 2 application with 3 different roles: Admin, Vendor, and User. All three of these users should have different login pages. What I'm struggling with is figuring out what to put in the security.yml to get unauthenticated (IS_AUTHENTICATED_ANONYMOUSLY) users on a certain url path /vendor for instance to redirect to something like /adminlogin versus just /login. I'm using FOSUserBundle right now, and it looks like everything redirects to /login.

Thanks!

Jake Sylvestre
  • 936
  • 3
  • 14
  • 39

1 Answers1

0

You could split the security configuration into three different firewalls: one for admin users, one for vendor users and one for other users. And, based on URL that user hits, you should redirect him to appropriate login form (if he is not logged in).

For example, if user visits example.com/admin/inventory, and he is not authenticated, you should redirect him to example.com/adminlogin

firewalls:
    admin_secured_area:
        pattern:   ^/admin
        ...
        form_login:
            login_path: /admin/login
            check_path: /admin/login_check
            default_target_path: /admin

    vendor_secured_area:
        pattern:   ^/vendor
        ...
        form_login:
            login_path: /vendor/login
            check_path: /vendor/login_check
            default_target_path: /vendor

    default:
      ...

Please take a look at this answer for more information: https://stackoverflow.com/a/24546275/5431686

Community
  • 1
  • 1
Matko Đipalo
  • 1,676
  • 1
  • 11
  • 23