【发布时间】:2014-07-24 04:22:52
【问题描述】:
谁能帮助我使用河豚进行 cakephp 2.4.2 身份验证,我是 cakephp 身份验证的新手,所以我用谷歌搜索了它,但没有找到任何解决我的问题的方法。
这是我的代码
对于应用控制器
public $components = array(
'Session',
'RequestHandler',
'Auth' => array(
'authenticate' => array(
'Form' => array(
'passwordHasher' => 'Blowfish'
)
)
)
);
对于模型
public function beforeSave($options = array()){
if (isset($this->data[$this->name]['password'])) {
$this->data[$this->name]['password'] = Security::hash($this->data[$this->alias]['password'], 'blowfish');
}
return true;
}
对于控制器
if ($this->Auth->login()) {
$this->redirect(array('controller' => 'admins', 'action' => 'dashboard', 'builder' => true));
} else {
$this->Session->write('flash', array('You Have entered wrong username or password.', 'failure'));
$this->redirect(array('controller' => 'users', 'action' => 'login', 'builder' => true));
}
【问题讨论】:
-
无法验证用户。
-
Security::hash已弃用,如果可能,请使用密码哈希类代替文档。
标签: cakephp cakephp-2.4 blowfish