Fix that logout of unauthenticated users throws exceptions

This commit is contained in:
Eric Lippmann 2014-10-01 08:13:17 +02:00
parent ebde422824
commit 266936b9b5
1 changed files with 4 additions and 2 deletions

View File

@ -142,14 +142,16 @@ class AuthenticationController extends ActionController
public function logoutAction() public function logoutAction()
{ {
$auth = $this->Auth(); $auth = $this->Auth();
if (! $auth->isAuthenticated()) {
$this->redirectToLogin();
}
$isRemoteUser = $auth->getUser()->isRemoteUser(); $isRemoteUser = $auth->getUser()->isRemoteUser();
$auth->removeAuthorization(); $auth->removeAuthorization();
if ($isRemoteUser === true) { if ($isRemoteUser === true) {
$this->_helper->layout->setLayout('login'); $this->_helper->layout->setLayout('login');
$this->_response->setHttpResponseCode(401); $this->_response->setHttpResponseCode(401);
} else { } else {
$this->rerenderLayout()->redirectToLogin(); $this->redirectToLogin();
} }
} }
} }