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 として正しく保存されます。
私のAppController:
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.