"Closes #3216, Allow condition overrides in AuthComponent::identify()"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6248 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-12-25 07:33:29 +00:00
parent aa667c4d61
commit b96a3a2e6f

View file

@ -690,12 +690,20 @@ class AuthComponent extends Object {
/**
* Identifies a user based on specific criteria.
*
* @param mixed $user Optional. The identity of the user to be validated.
* Uses the current user session if none specified.
* @param mixed $user Optional. The identity of the user to be validated.
* Uses the current user session if none specified.
* @param array $conditions Optional. Additional conditions to a find.
* @return array User record data, or null, if the user could not be identified.
* @access public
*/
function identify($user = null) {
function identify($user = null, $conditions = null) {
if ($conditions === false) {
$conditions = null;
} elseif (is_array($conditions)) {
$conditions = array_merge((array)$this->userScope, $conditions);
} else {
$conditions = $this->userScope;
}
if (empty($user)) {
$user = $this->user();
if (empty($user)) {
@ -732,14 +740,13 @@ class AuthComponent extends Object {
return false;
}
$model =& $this->getModel();
$data = $model->find(array_merge($find, $this->userScope), null, null, -1);
$data = $model->find(array_merge($find, $conditions), null, null, -1);
if (empty($data) || empty($data[$this->userModel])) {
return null;
}
} elseif (is_numeric($user)) {
// Assume it's a user's ID
$model =& $this->getModel();
$data = $model->find(array_merge(array($model->escapeField() => $user), $this->userScope));
$data = $model->find(array_merge(array($model->escapeField() => $user), $conditions));
if (empty($data) || empty($data[$this->userModel])) {
return null;