LoginSignup
1
0

More than 5 years have passed since last update.

CakePHP 3にてAuthComponent使用中、指定のアクションを公開する方法

Posted at

前提

  • src\Controller\Hoge\AppController.phpにてAuthコンポーネントを有効にしている
HogeController.php
<?php
namespace App\Controller\Hoge;

use App\Controller\Hoge\AppController;
use Cake\Event\Event;

class HogeController extends AppController
{
    /**
     * beforeFilter method
     * 
     * @param Event $event
     * @return void
     */
    public function beforeFilter(Event $event)
    {
        // testアクションを公開する
        $this->Auth->allow('test');

        // test、test2アクションを公開する
        $this->Auth->allow(['test', 'test2']);
    }

    public function test() { }
    public function test2() { }
}

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0