【发布时间】:2014-09-21 12:32:42
【问题描述】:
我是 php 和 cakephp 的新手,我正在学习 cakephp (http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html) 的简单身份验证和授权应用程序教程。一切似乎都运行良好。
当用户订阅时,我将添加一封电子邮件确认以激活帐户。在本教程中,密码使用的是 blowfishpassword 哈希器。我将它用作链接中的令牌以进行确认。
但我似乎无法将链接令牌与数据库中的密码进行比较...
$passwordHasher = new BlowfishPasswordHasher();
$motdepasse = $this->data['Utilisateur']['mot_passe'] = $passwordHasher->hash(
$this->data['Utilisateur']['mot_passe']
);
$link = array('controller'=>'utilisateurs','action'=>'activate',$this->Utilisateur->id
.'-'. $motdepasse);
public function activate($token) {
$token = explode('-',$token);
$user = $this->Utilisateur->find('first',array(
'conditions' => array('id' => $token[0],'Utilisateur.mot_passe' => Security::hash($token[1], 'blowfish', 'Utilisateur.mot_passe'))
));
debug($user);
debug($token[1]);
die();
}
你能帮帮我吗?谢谢大家!
【问题讨论】:
-
Wince 你是手动做的,你能检查一下每个的散列版本是什么,看看它们是否真的不同?
标签: cakephp