开发者

Role based redirect?

I have login and I want to if admin login go to admin/index, if user login go to home/index page. How to do it using security.yml in Symfony 2.0 Beta1? By default, now it's redirect to http://myapp.com/app_dev.php. Please help me?

I'm put my security.yml file:

security:
   encoders:
       App\SecurityBundle\Entity\User:
           algorithm: sha512
           encode-as-base64: true
           iterations: 10

   providers:
       backend:
           entity: { class: AppSecurityBundle:User, property:
username }

   firewalls:
       backend:
           pattern: /admin/.*
           form_login:
               check_path: /login_check
               login_path: /login
           logout: true
           security: true
           anonymous: true
       public:
           pattern: /.*
     开发者_如何学Go      security: false

   access_control:
       - { path: /admin/.*, role: ROLE_ADMIN }
       - { path: /.*, role: IS_AUTHENTICATED_ANONYMOUSLY }


You could set the default_target_path under the form_login configuration directive and point it to a controller which redirects the user based on his roles.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜