1
我正在使用Cake的Auth组件,并且似乎无法弄清楚如何在使用scope
时设置特定的闪存数据/错误消息。Cakephp验证范围错误消息
测试时由0
改变active
到1
,我可以确认scope
参数的作品,但是如果scope
返回false,我得到我的login
方法,Your username or password was incorrect.
相关的闪存数据。
UsersController
public function login(){
if($this->request->is('post')){
if($this->Auth->login()){
$this->Session->setFlash('You are logged in!');
return $this->redirect($this->Auth->redirect());
}
$this->Session->setFlash(__('Your username or password was incorrect.'));
}
}
AppController的
public $components = array(
'DebugKit.Toolbar',
'Acl',
'Auth' => array(
'authorize' => array(
'Actions' => array('actionPath' => 'controllers')
),
'authenticate' => array(
'Form' => array(
'fields' => array('username' => 'email'),
'scope' => array('active' => '1')
)
)
),
'Session'
);
public function beforeFilter() {
$this->Auth->loginAction = array(
'controller' => 'Users',
'action' => 'login'
);
$this->Auth->logoutRedirect = array(
'controller' => 'Users',
'action' => 'login'
);
$this->Auth->loginRedirect = array(
'controller' => 'Users',
'action' => 'index'
);
}
是否有可能结合特定错误消息为每个scope
参数和login
方法?