有没有办法将身份验证错误消息绑定到身份验证组件的作用域条件?
例如,假设我有:
'Auth' => array('authenticate' => array('Blowfish' => array('scope' => array('User.activated' => 1))));如果作用域条件失败,我希望设置一个错误。我需要能够将这与用户/通行证不正确时出现的错误区分开来。
这个是可能的吗?
发布于 2013-05-08 02:16:07
它将查找与用户名/密码组合和任何范围条件匹配的用户,或者不匹配。
public function login()
{
if ($this->request->is('post')) {
if ($this->Auth->login($this->data['User'])) {
// check activated field
if ($this->Auth->user('activated') == 1) {
// user is activated
$this->redirect(...);
} else {
// user is not activated
// log the user out
$this->Auth->logout();
// redirect to an error page for inactive users
$this->redirect(..);
}
}
// redirect to an error page for wrong username/password
$this->redirect(..);
}
}我应该澄清一下,您不应该在配置身份验证组件时指定作用域条件。
我希望这能帮到你!
https://stackoverflow.com/questions/16425232
复制相似问题