cakephp 3.0 博客教程认证错误
cakephp 3.0 blog tutorial authentication error
我是cakephp新手..直接从3.0开始的
我已按照博客教程 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
怎么了?不是应该允许添加用户而不需要认证吗?
如果您实施 public initialize()
方法
,请确保在 UsersController.php 中调用 parent::initialize()
确保 Auth Component
已正确加载到您的 AppController.php
文件中。
我是cakephp新手..直接从3.0开始的
我已按照博客教程 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
怎么了?不是应该允许添加用户而不需要认证吗?
如果您实施 public initialize()
方法
parent::initialize()
确保 Auth Component
已正确加载到您的 AppController.php
文件中。