From 3db632732c95f4af4a374172195a8c151a42a005 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 23 Apr 2013 01:35:04 +0530 Subject: [PATCH] Avoid unnecessary overhead if user record already available from session. --- lib/Cake/Controller/Component/AuthComponent.php | 11 ++++++----- .../Case/Controller/Component/AuthComponentTest.php | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index c90152bd1..0e3dc9d1a 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -667,6 +667,12 @@ class AuthComponent extends Component { * @return boolean true if a user can be found, false if one cannot. */ protected function _getUser() { + $user = $this->user(); + if ($user) { + $this->Session->delete('Auth.redirect'); + return true; + } + if (empty($this->_authenticateObjects)) { $this->constructAuthenticate(); } @@ -678,11 +684,6 @@ class AuthComponent extends Component { } } - $user = $this->user(); - if ($user) { - $this->Session->delete('Auth.redirect'); - return true; - } return false; } diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 124f9478c..47edc0536 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1368,6 +1368,7 @@ class AuthComponentTest extends CakeTestCase { $_SERVER['PHP_AUTH_USER'] = 'mariano'; $_SERVER['PHP_AUTH_PW'] = 'cake'; + AuthComponent::$sessionKey = false; $this->Auth->authenticate = array( 'Basic' => array('userModel' => 'AuthUser') );