2013年05月10日 / CakePHP
【CakePHP】$this->Auth->userScopeにご注意!?
CakePHP2.xを使用してシステムを作成していたんですが、引っかかった箇所の1つです。
ログイン画面などの認証時に’username’と’password’以外のフィールドで条件を付けたい場合に配列で指定するのに使用する…
$this->Auth->userScope=array('flg' => '0');
をUsersController.phpなど認証をかけるController.phpに使用すると思いますが、
どうやらCakePHP2.xから仕様が変わったようです。
下記のようにすると条件が付けれるようです。
$this->Auth->authenticate = array('Form' => Array('scope' => array('flg' => '0')));
【補足】
cake内にあります、
lib\Cake\Controller\Component\Auth\DigestAuthenticate.php
内を確認して見たところ…
64行目:
`scope` Additional conditions to use when looking up and authenticating users,
と書かれてました。
条件が付けれなかったはずです。
し、知らなかった…