2012-12-02 67 views
0

我嘗試了3天的時間在FOSUser中重定向以重定向記錄的人員以索引他們是否嘗試訪問登錄頁面,但不幸的是似乎沒有辦法做到這一點。FOSUser - 禁用登錄用戶的登錄頁面

我該怎麼做?

+0

看到此[回覆](http://stackoverflow.com/a/18783526/1119601) – naitsirch

回答

0

您可以重寫FOSUserBundle SecurityController loginAction()方法。在裏面,檢查用戶是否連接了$this->container->get('security.context')->getToken()->getUser();,如果需要的話用$this->redirect重定向。

+1

問題是,當我登錄時,我去登錄頁面,我成爲anononymous!所以如果我測試與is_object($ this-> get('security.context') - > getToken() - > getUser())它does not工作! – tannana

1

這在在loginAction延長一點應該做的伎倆..

$user = $this->container->get('security.context')->getToken()->getUser() 
if (is_object($user) && $user instanceof UserInterface) { 
    return new RedirectResponse($this->container->get('router')->generate('_your_route')); 
} 
+0

這個不能工作,因爲你還沒有登錄firewal ...所以你的security.context = NULL – Franky238

相關問題