3
我的symfony 2應用程序中遇到以下問題。symfony 2重定向如果用戶已登錄並且想要調用/登錄
當用戶已經登錄時,他仍然可以訪問路由/登錄。 避免這種情況的最佳方法是什麼?
我試圖重定向用戶,如果他想登錄,但這不起作用,因爲我認爲。
public function loginAction()
{
if (!$this->get('security.context')->isGranted('ROLE_USER')) {
// not logged in
...
code
...
..
.
} else {
// already logged in
$this->redirect($this->generateUrl('HereIsMyRouteName'));
}
}