cakephp 3身份验证不工作
我试图在cakephp3中使用Auth,但返回错误 我确信这些数据是正确的 请注意,密码字段大小为255个字符 sql日志仅返回用户的邮件文件,其中cakephp 3身份验证不工作,php,authentication,cakephp,model-view-controller,Php,Authentication,Cakephp,Model View Controller,我试图在cakephp3中使用Auth,但返回错误 我确信这些数据是正确的 请注意,密码字段大小为255个字符 sql日志仅返回用户的邮件文件,其中 phi_members.user_mail = 'gathuth@gmail.com' 为什么不包括用户密码!! 行结果为1 PhimembersController.php <?PHP namespace App\Controller; use App\Controller\AppController; use Cake\Even
phi_members.user_mail = 'gathuth@gmail.com'
为什么不包括用户密码!!
行结果为1
PhimembersController.php
<?PHP
namespace App\Controller;
use App\Controller\AppController;
use Cake\Event\Event;
Class PhimembersController extends AppController {
var $name="Phi_members";
public $components = array('RequestHandler');
public function index()
{
echo'Hello World';
}
public function show() {
$this->set('phi_members',$this->Phi_members->find('all'));
}
public function initialize()
{
parent::initialize();
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'loginRedirect' => [
'action' => 'index'] , 'loginAction' => [
'action' => 'login'
],
'authenticate' => [
'Form' => [
'userModel' => 'phi_members',
'fields' => ['username' => 'user_mail','password' => 'user_password']
]
]
]);
}
public function beforeFilter(Event $event)
{
$this->Auth->allow(['index', 'login']);
}
public function login()
{
if ($this->request->is('post')) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error(__('Invalid username or password, try again'));
}
}
}
?>
login.ctp
<h1><?= $this->Flash->render('auth') ?></h1>
<?= $this->Form->create(); ?>
<fieldset>
<legend><?= __('Please enter your username and password') ?></legend>
<?= $this->Form->input('user_mail') ?>
<?= $this->Form->input('user_password') ?>
</fieldset>
<?= $this->Form->button(__('login')); ?>
<?= $this->Form->end() ?>
有什么帮助吗