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
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -313,7 +313,9 @@ public function userTitle(UserInterface $user = NULL) {
   *   A redirection to home page.
   */
  public function logout() {
    if ($this->currentUser()->isAuthenticated()) {
      user_logout();
    }
    return $this->redirect('<front>');
  }

+9 −0
Original line number Diff line number Diff line
@@ -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);
  }

}
+1 −1
Original line number Diff line number Diff line
@@ -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'