Symfony2: Check user authentication based on path

后端 未结 3 595
悲哀的现实
悲哀的现实 2020-12-06 03:02

in Symfony2, is it possible to check if user is authenticated to access the URl he requested. What I want to do is, i dont want to allow a logged in user to go back to regis

3条回答
  •  盖世英雄少女心
    2020-12-06 03:32

    You can do not only inside security.yml options, but also via controller, like this:

    if($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
          return $this->redirect($this->generateUrl('homepage'));
    }
    

提交回复
热议问题