Skip to content

Commit

Permalink
Move 'Auth.redirect' session value clearing from AuthComponent::shutd…
Browse files Browse the repository at this point in the history
…own() to prevent unnecessary session start.

Closes #3702
  • Loading branch information
ADmad committed Mar 14, 2013
1 parent 0900c32 commit 8e299fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
15 changes: 2 additions & 13 deletions lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -608,7 +608,7 @@ public function login($user = null) {
}

/**
* Log a user out.
* Log a user out.
*
* Returns the login action to redirect to. Triggers the logout() method of
* all the authenticate objects, so they can perform custom logout logic.
Expand Down Expand Up @@ -680,6 +680,7 @@ protected function _getUser() {

$user = $this->user();
if ($user) {
$this->Session->delete('Auth.redirect');
return true;
}
return false;
Expand Down Expand Up @@ -791,18 +792,6 @@ public static function password($password) {
return Security::hash($password, null, true);
}

/**
* Component shutdown. If user is logged in, wipe out redirect.
*
* @param Controller $controller Instantiating controller
* @return void
*/
public function shutdown(Controller $controller) {
if ($this->loggedIn()) {
$this->Session->delete('Auth.redirect');
}
}

/**
* Check whether or not the current user has data in the session, and is considered logged in.
*
Expand Down
14 changes: 0 additions & 14 deletions lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php
Expand Up @@ -1108,20 +1108,6 @@ public function testStatelessAuthWorksWithUser() {
$this->assertEquals('mariano', $result);
}

/**
* Tests that shutdown destroys the redirect session var
*
* @return void
*/
public function testShutDown() {
$this->Auth->Session->write('Auth.User', 'not empty');
$this->Auth->Session->write('Auth.redirect', 'foo');
$this->Controller->Auth->loggedIn(true);

$this->Controller->Auth->shutdown($this->Controller);
$this->assertNull($this->Auth->Session->read('Auth.redirect'));
}

/**
* test $settings in Controller::$components
*
Expand Down

0 comments on commit 8e299fc

Please sign in to comment.