Skip to content

Commit

Permalink
Added ability for Auth login to use contain
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrang committed Apr 5, 2012
1 parent 72cb96b commit bf628c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/Cake/Controller/Component/Auth/BaseAuthenticate.php
Expand Up @@ -30,6 +30,7 @@ abstract class BaseAuthenticate {
* - `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.
* - `contain` Extra models to contain and store in session.
*
* @var array
*/
Expand All @@ -40,7 +41,8 @@ abstract class BaseAuthenticate {
),
'userModel' => 'User',
'scope' => array(),
'recursive' => 0
'recursive' => 0,
'contain' => array(),
);

/**
Expand Down Expand Up @@ -82,13 +84,16 @@ protected function _findUser($username, $password) {
}
$result = ClassRegistry::init($userModel)->find('first', array(
'conditions' => $conditions,
'recursive' => (int)$this->settings['recursive']
'recursive' => (int)$this->settings['recursive'],
'contain' => $this->settings['contain'],
));
if (empty($result) || empty($result[$model])) {
return false;
}
unset($result[$model][$fields['password']]);
return $result[$model];
$user = $result[$model];
unset($user[$fields['password']]);
unset($result[$model]);
return array_merge($user, $result);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Controller/Component/Auth/BasicAuthenticate.php
Expand Up @@ -50,6 +50,7 @@ class BasicAuthenticate extends BaseAuthenticate {
* - `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.
* - `contain` Extra models to contain and store in session.
* - `realm` The realm authentication is for. Defaults the server name.
*
* @var array
Expand All @@ -62,6 +63,7 @@ class BasicAuthenticate extends BaseAuthenticate {
'userModel' => 'User',
'scope' => array(),
'recursive' => 0,
'contain' => array(),
'realm' => '',
);

Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/Controller/Component/Auth/DigestAuthenticate.php
Expand Up @@ -63,6 +63,8 @@ class DigestAuthenticate 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.
* - `contain` Extra models to contain and store in session.
* - `realm` The realm authentication is for, Defaults to the servername.
* - `nonce` A nonce used for authentication. Defaults to `uniqid()`.
* - `qop` Defaults to auth, no other values are supported at this time.
Expand All @@ -79,6 +81,7 @@ class DigestAuthenticate extends BaseAuthenticate {
'userModel' => 'User',
'scope' => array(),
'recursive' => 0,
'contain' => array(),
'realm' => '',
'qop' => 'auth',
'nonce' => '',
Expand Down

0 comments on commit bf628c4

Please sign in to comment.