mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-02 17:42:41 +00:00
updating auth component and test with additional checks for missing data
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7979 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
4a636b93a8
commit
e496fc9434
2 changed files with 34 additions and 15 deletions
|
@ -297,23 +297,29 @@ class AuthComponent extends Object {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
$username = $controller->data[$this->userModel][$this->fields['username']];
|
||||
$password = $controller->data[$this->userModel][$this->fields['password']];
|
||||
|
||||
$data = array(
|
||||
$this->userModel . '.' . $this->fields['username'] => $username,
|
||||
$this->userModel . '.' . $this->fields['password'] => $password
|
||||
);
|
||||
$isValid = !empty($controller->data[$this->userModel][$this->fields['username']]) &&
|
||||
!empty($controller->data[$this->userModel][$this->fields['password']]);
|
||||
|
||||
if ($this->login($data)) {
|
||||
if ($this->autoRedirect) {
|
||||
$controller->redirect($this->redirect(), null, true);
|
||||
if ($isValid) {
|
||||
$username = $controller->data[$this->userModel][$this->fields['username']];
|
||||
$password = $controller->data[$this->userModel][$this->fields['password']];
|
||||
|
||||
$data = array(
|
||||
$this->userModel . '.' . $this->fields['username'] => $username,
|
||||
$this->userModel . '.' . $this->fields['password'] => $password
|
||||
);
|
||||
|
||||
if ($this->login($data)) {
|
||||
if ($this->autoRedirect) {
|
||||
$controller->redirect($this->redirect(), null, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
$this->Session->setFlash($this->loginError, 'default', array(), 'auth');
|
||||
$controller->data[$this->userModel][$this->fields['password']] = null;
|
||||
}
|
||||
|
||||
$this->Session->setFlash($this->loginError, 'default', array(), 'auth');
|
||||
$controller->data[$this->userModel][$this->fields['password']] = null;
|
||||
return false;
|
||||
} else {
|
||||
if (!$this->user()) {
|
||||
|
@ -794,7 +800,7 @@ class AuthComponent extends Object {
|
|||
if (empty($data) || empty($data[$this->userModel])) {
|
||||
return null;
|
||||
}
|
||||
} elseif (!empty($user)) {
|
||||
} elseif (!empty($user) && is_string($user)) {
|
||||
$model =& $this->getModel();
|
||||
$data = $model->find(array_merge(array($model->escapeField() => $user), $conditions));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue