0

I’ve built a complete private site. Everything seems to work. When users wants to log out, they are redirect from /user/logout /user/login?destination=/, which seems the normal behavior, for what I understand.

A client told me he is not redirected to /user/login?destination=/ but stays on /user/logout, getting an Access Denied error.

I can’t reproduce this issue.

How is the logout supposed to work? Is the redirect from /user/logout to /user/login?destination=/ the normal behavior?

1

Is the redirect from /user/logout to /user/login?destination=/

No, the normal behavior is to redirect to the frontpage. You probably have a module installed which issues a second redirect when the logged out user doesn't have access to the frontpage.

How is the user logout process supposed to work?

This is the core controller as example:

UserController::logout

  /**
   * Logs the current user out.
   *
   * @return \Symfony\Component\HttpFoundation\RedirectResponse
   *   A redirection to home page.
   */
  public function logout() {
    user_logout();
    return $this->redirect('<front>');
  }

So you only need to call user_logout() in custom code to implement your own logout.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.