mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Fixing order of operations for AuthComponent
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4480 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a7653e4d80
commit
b5dc025a61
1 changed files with 12 additions and 12 deletions
|
@ -172,10 +172,12 @@ class AuthComponent extends Object {
|
|||
* @return void
|
||||
*/
|
||||
function startup(&$controller) {
|
||||
|
||||
if (low($controller->name) == 'app' || (low($controller->name) == 'tests' && DEBUG > 0)) {
|
||||
return;
|
||||
}
|
||||
if (!$this->_setDefaults($controller)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hash incoming passwords
|
||||
if (isset($controller->data[$this->userModel])) {
|
||||
|
@ -184,9 +186,10 @@ class AuthComponent extends Object {
|
|||
$controller->data[$this->userModel][$this->fields['password']] = Security::hash($controller->data[$this->userModel][$this->fields['password']]);
|
||||
}
|
||||
}
|
||||
$this->data = $controller->data;
|
||||
|
||||
if (!$this->_setDefaults($controller)) {
|
||||
return;
|
||||
if ($this->allowedActions == array('*') || in_array($controller->action, $this->allowedActions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($controller->params['url']['url'])) {
|
||||
|
@ -249,12 +252,6 @@ class AuthComponent extends Object {
|
|||
* @return void
|
||||
*/
|
||||
function _setDefaults(&$controller) {
|
||||
$this->data = $controller->data;
|
||||
|
||||
if ($this->allowedActions == array('*') || in_array($controller->action, $this->allowedActions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->userModel)) {
|
||||
$classes = array_values(array_intersect(
|
||||
array_map('strtolower', get_declared_classes()),
|
||||
|
@ -388,7 +385,7 @@ class AuthComponent extends Object {
|
|||
*/
|
||||
function validate($object, $user = null) {
|
||||
$user = $this->identify($user);
|
||||
if ($user == null) {
|
||||
if (empty($user)) {
|
||||
return false;
|
||||
}
|
||||
pr($user);
|
||||
|
@ -449,8 +446,11 @@ class AuthComponent extends Object {
|
|||
* @return array User record data, or null, if the user could not be identified.
|
||||
*/
|
||||
function identify($user = null) {
|
||||
if ($user == null) {
|
||||
$model =& $this->getUserModel();
|
||||
if (empty($user)) {
|
||||
$user = $this->user();
|
||||
if (empty($user)) {
|
||||
return null;
|
||||
}
|
||||
} else if (is_object($user) && is_a($user, 'Model')) {
|
||||
if (!$user->exists()) {
|
||||
return null;
|
||||
|
|
Loading…
Add table
Reference in a new issue