CakePHP 自定义无状态身份验证

CakePHP Custom Stateless Authentication

我正在为 CakePHP 编写自己的无状态身份验证 class。我相信我已经正确编写了 class,当我手动触发 $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]

链接

当我更改这个后问题就解决了

$this->Auth->config('checkAuthIn', ['Controller.initialize']);

至此

$this->Auth->config('checkAuthIn', 'Controller.initialize');

(从数组中取出)