所以,我在我的依赖注入中设置了安全组件,如下所示...
我错过了什么???
--services.php--
$di->set('security', function(){
$security = new Phalcon\Security();
//Set the password hashing factor to 11 rounds
$security->setWorkFactor(11);
return $security;
}, true);
--Custom Auth Library (auth.php)--
$user = Users::findFirstByEmail($login);
if ($user) {
if ($this->security->checkHash($password, $user->password)) {
return true;
}
}
return false;
但是,出于某些原因,这总是返回false...所以为了调试,我尝试使用PHP的password_verify函数,下面的代码直接在我的视图中:
//Returns false
var_dump($this->security->checkHash('password', '$2a$12$aSa7zLEd24zjh2aoUasxd.hbxIm8IQ0/vMf/8p4LTYI3VtZMJ62Pe'));
//Returns True
var_dump(password_verify('password', '$2a$12$aSa7zLEd24zjh2aoUasxd.hbxIm8IQ0/vMf/8p4LTYI3VtZMJ62Pe'));
我错过了什么???
var_dump
不会返回任何内容,它只是打印到屏幕上。 - gen_Ericpassword_hash
还是$this->security->hash
? - gen_Eric