Skip to content

Commit

Permalink
Added 'recursive' settings option to BaseAuthenticate and BasicAuthen…
Browse files Browse the repository at this point in the history
…ticate to have a bit more fine grained control in custom Authenticate objects.
  • Loading branch information
Thomas Ploch committed Oct 19, 2011
1 parent 485c15d commit 521dff8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Cake/Controller/Component/Auth/BaseAuthenticate.php
Expand Up @@ -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
*/
Expand All @@ -38,7 +39,8 @@ abstract class BaseAuthenticate {
'password' => 'password'
),
'userModel' => 'User',
'scope' => array()
'scope' => array(),
'recursive' => 0
);

/**
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Controller/Component/Auth/BasicAuthenticate.php
Expand Up @@ -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
Expand All @@ -59,6 +60,7 @@ class BasicAuthenticate extends BaseAuthenticate {
),
'userModel' => 'User',
'scope' => array(),
'recursive' => 0,
'realm' => '',
);

Expand Down
Expand Up @@ -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);
Expand Down

0 comments on commit 521dff8

Please sign in to comment.