3 Apr 2017

[Cakephp2] cakedc/users プラグインと ACL ビヘイビアを併用するために必要な事

CakePHP2なんて、本当に今更ですが、2017年4月現在、cakedc/users とACLビヘイビアを併用するには、それぞれのチュートリアルに沿って変更をする点の他に、
例えばAppController.php の中の $components の設定に以下の一行を書き加える必要があります。
     'userModel' => 'AppUser',
該当ブロックは以下の様になります。
 public $components = array(
  'Session',
  'Flash',
  'Acl',
  'Auth' => array(
   'loginAction' => array(
    'controller' => 'app_users',
    'action' => 'login',
    'plugin' => false
   ),
   'loginRedirect' => array(
    'controller' => 'posts',
    'action' => 'index'
   ),
   'logoutRedirect' => array(
    'controller' => 'pages',
    'action' => 'display',
    'home'
   ),
   'flash' => array(
    'element' => 'alert',
    'key' => 'auth',
    'params' => array(
     'plugin' => 'BoostCake',
     'class' => 'alert-error'
    )
   ),
   'authorize' => array(
    'Actions' => array(
     'actionPath' => 'controllers',
     'userModel' => 'AppUser',
    ),
   ),
   //'authError' => 'Did you really think you are allowed to see that?',
   'authenticate' => array(
    'Form' => array(
     'passwordHasher' => 'Blowfish',
     'userModel' => 'AppUser',
     'fields' => array(
      'username' => 'username', //Default is 'username' in the userModel
      'password' => 'password'  //Default is 'password' in the userModel
     ),
    ),
   ),
  ),
  'DebugKit.Toolbar'
 );
'userModel' => 'AppUser',
at your settings for Auth Component Section in AppContoroller.php.
whole block would be:
 public $components = array(
  'Session',
  'Flash',
  'Acl',
  'Auth' => array(
   'loginAction' => array(
    'controller' => 'app_users',
    'action' => 'login',
    'plugin' => false
   ),
   'loginRedirect' => array(
    'controller' => 'posts',
    'action' => 'index'
   ),
   'logoutRedirect' => array(
    'controller' => 'pages',
    'action' => 'display',
    'home'
   ),
   'flash' => array(
    'element' => 'alert',
    'key' => 'auth',
    'params' => array(
     'plugin' => 'BoostCake',
     'class' => 'alert-error'
    )
   ),
   'authorize' => array(
    'Actions' => array(
     'actionPath' => 'controllers',
     'userModel' => 'AppUser',
    ),
   ),
   //'authError' => 'Did you really think you are allowed to see that?',
   'authenticate' => array(
    'Form' => array(
     'passwordHasher' => 'Blowfish',
     'userModel' => 'AppUser',
     'fields' => array(
      'username' => 'username', //Default is 'username' in the userModel
      'password' => 'password'  //Default is 'password' in the userModel
     ),
    ),
   ),
  ),
  'DebugKit.Toolbar'
 );