LoginSignup
0
1

More than 5 years have passed since last update.

CakePHP3でAuthComponentを利用した時のPageController経由のページの許可方法

Posted at

CakePHP3でのページ作成でハマったところやちょっとしたつまづきを記録するその1

CakePHP 3.4
PHP 7.0.16

困ったこと

AppControllerにてAuthComponentをonにした時にRoot直下のページが映らなくなった

解決方法

beforeFilter()$controller->Auth->allow(['display'])を指定すれば良い

試行錯誤

  • phpunitのテストが落ちていたことで発覚
  • beforeFilter()への到達は確認
  • $controller->Auth->allow(['index', 'home'])など試行錯誤
  • /の処理については特殊なのかと思いconfig/routes.phpを確認
    • $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
    • actionをdisplayとして振り分けていることを知る
  • 解決方法のbeforeFilter()$controller->Auth->allow(['display'])を指定
0
1
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
0
1