尝试登录用户时出现以下错误:
Call to a member function login() on a non-object
我的登录操作使用外部模型。动作是:
public function login() {
$this->loadModel('User');
if ($this->request->is('post')) {
$theUser = $this->User->find('first', array('conditions' => array('User.username' => $this->request->data['User']['username'])));
if($theUser['User']['activated'] == TRUE){
if ($this->Auth->login($this->request->data)){
$this->Session->setFlash('Logged in successfully');
$this->redirect(array('controller' => 'admin', 'action' => 'index'));
} else {
$this->Session->setFlash('Username or password is incorrect');
}
}else $this->Session->setFlash('User not yet activated. Please Contact administrator.');
}
}
传递给的请求数据$this->Auth->login
是:
array(
'User' => array(
'password' => '*****',
'username' => 'admin'
)
)
$this->Auth->login($this->request->data)
是导致致命错误的行。
有人可以解释错误的确切含义以及可能导致它的原因吗?