CakePHP 3.6身份验证不';行不通
我正在学习CakePHP教程:CakePHP 3.6身份验证不';行不通,php,cakephp,Php,Cakephp,我正在学习CakePHP教程: 我的CakePHP版本是:3.6.0 我的Php版本是:7.2 这是我的src\Controller\AppController.php <?php namespace App\Controller; use Cake\Controller\Controller; use Cake\Event\Event; class AppController extends Controller { public function initialize()
我的CakePHP版本是:3.6.0
我的Php版本是:7.2 这是我的src\Controller\AppController.php
<?php
namespace App\Controller;
use Cake\Controller\Controller;
use Cake\Event\Event;
class AppController extends Controller
{
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authenticate' => [
'Form' => [
'fields' => [
'username' => 'email',
'password' => 'password'
]
]
],
'loginAction' => [
'controller' => 'Users',
'action' => 'login'
],
'unauthorizedRedirect' => $this->referer()
]);
$this->Auth->allow(['display']);
}
}
我创建了src\Template\Users\login.ctp文件:
<h1>Login</h1>
<?= $this->Form->create() ?>
<?= $this->Form->control('email') ?>
<?= $this->Form->control('password') ?>
<?= $this->Form->button('Login') ?>
<?= $this->Form->end() ?>
登录
我的浏览器正在通知错误:ERR\u太多\u重定向
如果我尝试转到以下url:localhost:8765/bookmarks
浏览器重定向到:您应该将
登录
操作添加到允许列表中:
$this->Auth->allow([
'display',
'login',
]);
或者阅读以下评论:
$this->Auth->allow([
'display',
'login',
]);