首页 > 解决方案 > 在 null 上调用成员函数 addUauthenticatedActions()(CakePHP 身份验证)

问题描述

我正在尝试实现 CMS 教程 - CakePHP 的身份验证,到目前为止我只是在尝试实现登录页面,但它在这一行给了我一个错误

$this->Authentication->addUnauthenticatedActions(['login']);

错误:在 null 上调用成员函数 addUnauthenticatedActions()

用户控制器:

public function beforeFilter(\Cake\Event\EventInterface $event){
parent::beforeFilter($event);
// Configure the login action to not require authentication, preventing
// the infinite redirect loop issue
$this->Authentication->addUnauthenticatedActions(['login']);
}

public function initialize() :void{
    $this->loadComponent('Flash');
    $this->loadComponent('Authentication.Authentication');
}

标签: authenticationcakephpcakephp-4.x

解决方案


推荐阅读