Skip to content
Snippets Groups Projects
Commit 1b628f44 authored by catch's avatar catch
Browse files

Issue #2193803 by wturrell, ridhimaabrol24, mglaman, Pavan B S,...

Issue #2193803 by wturrell, ridhimaabrol24, mglaman, Pavan B S, narendra.rajwar27, abhisekmazumdar, dpi, manish.upadhyay, pankaj.singh, paulocs, Charles Belov, quietone, catch, jim_at_miramontes, dawehner, goodboy: Anonymous users receive access denied when attempting to logout
parent cc866657
No related branches found
No related tags found
No related merge requests found
......@@ -313,7 +313,9 @@ public function userTitle(UserInterface $user = NULL) {
* A redirection to home page.
*/
public function logout() {
user_logout();
if ($this->currentUser()->isAuthenticated()) {
user_logout();
}
return $this->redirect('<front>');
}
......
......@@ -141,4 +141,13 @@ public function testAccountPageTitles() {
$this->assertLinkByHref(\Drupal::urlGenerator()->generate('user.page'), 0);
}
/**
* Ensures that logout url redirects an anonymous user to the front page.
*/
public function testAnonymousLogout() {
$this->drupalGet('user/logout');
$this->assertSession()->addressEquals('/');
$this->assertSession()->statusCodeEquals(200);
}
}
......@@ -11,7 +11,7 @@ user.logout:
defaults:
_controller: '\Drupal\user\Controller\UserController::logout'
requirements:
_user_is_logged_in: 'TRUE'
_access: 'TRUE'
user.admin_index:
path: '/admin/config/people'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment