2013-10-15 72 views
1
页面

在我的应用我有登录和注销行为CakePHP的 - 登录和注销重定向后,不重装

function login() 
{ 
    $this->layout = 'cake'; 

    if ($this->request->is('post')) { 

     $this->Auth->login(); 
     if ($this->Auth->login()) { 
      $this->redirect(array(
       'controller' => 'photos', 
       'action' => 'flow' 
      )); 
     } 

     else { 
      $this->Session->setFlash('Nome de usuário ou senha incorreto', 'default', array(
       'class' => 'flash_fail' 
      )); 
     } 
    } 

} 

但是,当用户登录,并转到photos/flow用户名不出现。我需要刷新页面(F5)以显示用户信息。 有一种重定向和刷新信息的方法? 谢谢。

+0

为什么要使用'$ this-> Auth-> login();'两次?这是一个明确的杀手:)第二个将永远返回false。 – mark

回答

0
if ($this->request->is('post')) { 
     if ($this->Auth->login()) { 
      $this->redirect(array('controller' => 'photos','action' => 'flow')); 
     } else { 
$this->Session->setFlash('something went wrong', 'flash', array('alert' => 'error')); 
}