CakeDC/Usersプラグインを使ってユーザー認証の開発テストを行っております。
こちらを参考にログアウト処理を実装しようとヘルパーを使いたいと考えていますが下記のエラーが出ておりlogoutメソッドが読み込めていないようです。
アドバイスいただけると幸いです。
Call to a member function logout() on boolean
【基本情報】
PHP 7.0
CakePHP Ver3.6.1
CakeDC/Users Ver 確認方法が不明ですが9/6時点で最新ダウンロード
【URL】
http://localhost/rd_logintest/top/logout
【TopController.php】
<?php namespace App\Controller; class TopController extends AppController { public function initialize(){ parent::initialize(); //$this->Auth->allow(['index']); //認証を許可 $this->viewBuilder()->layout('Top'); $this->viewBuilder()->autoLayout(true); $this->autoRender=true; } public function index(){ } public function logout(){ $this->User->logout(); } }
【Bootstrap.php】
略 Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]); Configure::write('Users.config', ['users']); Configure::write('Users.Social.login', true); //to enable social login
【AppView.php】
略 public function initialize() { parent::initialize(); $this->loadHelper('CakeDC/Users.User'); }
回答1件
あなたの回答
tips
プレビュー