From 521dff84686a5d9f529159a6cb26b1ce4897172f Mon Sep 17 00:00:00 2001 From: Thomas Ploch Date: Wed, 19 Oct 2011 17:54:08 +0200 Subject: [PATCH] Added 'recursive' settings option to BaseAuthenticate and BasicAuthenticate to have a bit more fine grained control in custom Authenticate objects. --- lib/Cake/Controller/Component/Auth/BaseAuthenticate.php | 6 ++++-- lib/Cake/Controller/Component/Auth/BasicAuthenticate.php | 2 ++ .../Controller/Component/Auth/BasicAuthenticateTest.php | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php index 4d2b73138f0..151d350259f 100644 --- a/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php @@ -29,6 +29,7 @@ abstract class BaseAuthenticate { * - `userModel` The model name of the User, defaults to User. * - `scope` Additional conditions to use when looking up and authenticating users, * i.e. `array('User.is_active' => 1).` + * - `recursive` The value of the recursive key passed to find(). Defaults to 0. * * @var array */ @@ -38,7 +39,8 @@ abstract class BaseAuthenticate { 'password' => 'password' ), 'userModel' => 'User', - 'scope' => array() + 'scope' => array(), + 'recursive' => 0 ); /** @@ -80,7 +82,7 @@ protected function _findUser($username, $password) { } $result = ClassRegistry::init($userModel)->find('first', array( 'conditions' => $conditions, - 'recursive' => 0 + 'recursive' => $this->settings['recursive'] )); if (empty($result) || empty($result[$model])) { return false; diff --git a/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php index 347deec9fa9..f55fd35db30 100644 --- a/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php @@ -48,6 +48,7 @@ class BasicAuthenticate extends BaseAuthenticate { * - `userModel` The model name of the User, defaults to User. * - `scope` Additional conditions to use when looking up and authenticating users, * i.e. `array('User.is_active' => 1).` + * - `recursive` The value of the recursive key passed to find(). Defaults to 0. * - `realm` The realm authentication is for. Defaults the server name. * * @var array @@ -59,6 +60,7 @@ class BasicAuthenticate extends BaseAuthenticate { ), 'userModel' => 'User', 'scope' => array(), + 'recursive' => 0, 'realm' => '', ); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php index 2699c17f933..0c354008d5c 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php @@ -47,6 +47,7 @@ public function setUp() { 'fields' => array('username' => 'user', 'password' => 'password'), 'userModel' => 'User', 'realm' => 'localhost', + 'recursive' => 0 )); $password = Security::hash('password', null, true);