FOSUserBundle redirect from login page after logged in

前端 未结 4 818
北恋
北恋 2020-12-02 15:05

I simply want that if admin user or front end user try to access login page even after logged in

/admin/login (admin user) 

OR



        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 15:14

    Just redirect in the controller of the page that you added in default_target_path to the wanted direction, for example, if you put for default_target_path: /index and index is an action defined in HomePageCOntroller, go to HomePageCOntroller, test if the current user is admin or not with:

    if (($this->container->get('security.context')->isGranted('ROLE_ADMIN'))) 
    

    and then redircet him to the admin space.

提交回复
热议问题