Browse files

Avoid unnecessary overhead if user record already available from sess…

…ion.
  • Loading branch information...
1 parent 06a5c50 commit 3db632732c95f4af4a374172195a8c151a42a005 @ADmad ADmad committed Apr 22, 2013
View
11 lib/Cake/Controller/Component/AuthComponent.php
@@ -667,6 +667,12 @@ public static function user($key = null) {
* @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 @@ protected function _getUser() {
}
}
- $user = $this->user();
- if ($user) {
- $this->Session->delete('Auth.redirect');
- return true;
- }
return false;
}
View
1 lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php
@@ -1368,6 +1368,7 @@ public function testStatelessAuthNoSessionStart() {
$_SERVER['PHP_AUTH_USER'] = 'mariano';
$_SERVER['PHP_AUTH_PW'] = 'cake';
+ AuthComponent::$sessionKey = false;
$this->Auth->authenticate = array(
'Basic' => array('userModel' => 'AuthUser')
);

0 comments on commit 3db6327

Please sign in to comment.