请问我真的需要帮助,我在论坛上尝试了几乎所有内容
方法$ this-> Auth-> identify();总是返回false
数据库中密码的长度为varchar(255)
我的cakephp版本是3.6.8
candidatcontroller
public function login()
{
if ($this->request->is('post'))
{
$candidat = $this->Auth->identify();
if ($candidat)
{
$this->Auth->setUser($candidat);
return $this->redirect(['Controller'=>'Candidat','action'=>'index']);
}
$this->Flash->error(__('The candidat could not be saved Please try again.'));
}
}
appcontroller
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler', [
'enableBeforeRedirect' => false,
]);
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authError' => 'Vous croyez vraiment que vous pouvez faire cela?',
'authenticate' => [
'Form' => [
'fields' => ['username' => 'email','password' => 'password']
]
],
'loginAction' => [
'controller' => 'candidat',
'action' => 'login',
],
'storage' => 'Session'
]);
}
登录
<?= $this->Form->create() ?>
<fieldset>
<legend><?= __('login') ?></legend>
<?php
echo $this->Form->control('Email_cand',['label'=>'Email']);
echo $this->Form->control('password',['label'=>'mot de passe']);
?>
</fieldset>
<?= $this->Form->button(__('connecter')) ?>
<?= $this->Form->end() ?>