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
Branches
Tags
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -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.
Please register or to comment