我正在为CakePHP编写自己的无状态身份验证类。我相信我已经正确编写了类,当我手动触发$this->Auth->identify()
方法时,它会正确地登录我。
我遇到了麻烦,所以它会让我登录每一页......你知道,无国籍......
在我AppController::initialize
我有以下
$this->loadComponent('Auth');
$this->Auth->config('authenticate', ['CustomAuthenticate']);
$this->Auth->config('checkAuthIn', ['Controller.initialize']);
AppController::beforeRender
有
$auth_user = TableRegistry::get('Users')->getFullUser( $this-> Auth->user('id') );
我认为checkAuthIn
的部分将成为使它全部奏效的神奇线条,但我想它不是(除非我还需要做其他事情)。
我目前正在Fatal Error(1): Call to a memeber function user() on a non-object in [.../src/Controller/AppController.php, line 78]
答案 0 :(得分:0)
当我改变这个
时问题得到解决$this->Auth->config('checkAuthIn', ['Controller.initialize']);
到这个
$this->Auth->config('checkAuthIn', 'Controller.initialize');
(把它从数组中取出)