我是一个新手,CakePHP的..我直接从3.0CakePHP的3.0博客教程认证错误
启动它,我也跟着教程BLOG 1,2和现在所面临的博客教程错误 - Authentication and Authorization
// src/Controller/UsersController.php
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
// Allow users to register and logout.
// You should not add the "login" action to allow list. Doing so would
// cause problems with normal functioning of AuthComponent.
$this->Auth->allow(['add', 'logout']);
}
当我尝试访问/ users/add页面时出现错误。
Error: Call to a member function allow() on a non-object
File : src\Controller\UsersController.php
出了什么问题?它不应该允许添加用户没有身份验证?
您是否在'AppController'中添加了'auth'作为组件? – 2015-04-04 07:28:11
本教程中的这一部分:'认证(登录和注销)'http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html – 2015-04-04 07:31:09
是的存在'公共函数初始化() { $ this-> loadComponent('Flash'); $这 - > loadComponent( '验证',[ 'loginRedirect'=> [ '控制器'=> '文章', '动作'=> '索引' ], 'logoutRedirect'=> [ ' controller'=>'Pages', 'action'=>'display', 'home' ] ]); }' – 2015-04-04 07:42:24