我正在尝试为我的 cakephp 应用程序设置 bcrypt。我之前在另一个应用程序上设置过它,并且有效。但是,在基本上将加密代码从一个应用程序复制/粘贴到另一个应用程序之后,它将密码保存为空白。
数据库设置正确,密码字段为 varchar(225)。
我得出的结论是以下代码行是导致问题的原因;
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$hash = Security::hash($this->data['User']['password'], 'blowfish');
$this->data['User']['password'] = $hash;
}
return true;
}
如果我要取出这个 beforeSave 功能,我的密码将正确保存为明文。如果我要更换
$this->data['User']['password'] = $hash;
和
$this->data['User']['password'] = 'testpassword';
它会正确地将密码保存为 testpassword。
我的应用控制器:
public $components = array(
'Session',
'Auth' => array(
'authenticate' =>'Blowfish',
'logoutRedirect' => array('controller'=>'fronts', 'action'=>'index'),
'authorize' => array('Controller')
)
);
我的表格:
<?php echo $this->Session->flash('auth'); ?>
<?php echo $this->Form->create('User'); ?>
<fieldset>
<?php
echo $this->form->input('username', array('placeholder' => 'Username', 'label' => false));
echo $this->form->input('password', array('placeholder' => 'Password', 'label' => false));
echo $this->form->submit('CREATE', array('class' => 'button'));
?>
</fieldset>
<?php echo $this->Form->end(); ?>
尝试登录时,虽然我知道它不起作用,但我收到此错误
Authentication adapter Blowfish was not found.