This is quite a major issue and I'm wondering why I'm the only one experiencing it.

If you set the destination path variable to something else then user/logout, you will get redirected there but you are not going to be logged out. How so?

/**
 * Redirects user to defined page.
 */
function _logouttab_redirect_url() {
  drupal_goto(variable_get('logouttab_url', 'user/logout'));
}

This does nothing than redirecting the user. I will submit a patch in 5 minutes.

Comments

donSchoe’s picture

StatusFileSize
new553 bytes

Patch attached, it duplicates the behaviour of user_logout() but uses the custom redirect path.

donSchoe’s picture

Status: Active » Needs review
donSchoe’s picture

Status: Needs review » Needs work

Ok the default value 'user/logout' throws a permission denied warning. It should be changed to 'user' by default.

donSchoe’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

New patch attached.

andypost’s picture

  1. +++ b/logouttab.module
    @@ -27,10 +27,14 @@ function logouttab_menu() {
    -  drupal_goto(variable_get('logouttab_url', 'user/logout'));
    
    @@ -41,7 +45,7 @@ function logouttab_admin_settings() {
    +    '#default_value' => variable_get('logouttab_url', 'user'),
    

    This variable holds a URL to redirect for logout.

  2. +++ b/logouttab.module
    @@ -27,10 +27,14 @@ function logouttab_menu() {
    +  global $user;
    +  watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
    +  module_invoke_all('user_logout', $user);
    +  session_destroy();
    +  drupal_goto(variable_get('logouttab_url', 'user'));
    

    no reason to implement own logout when there's core's one

andypost’s picture

Status: Needs review » Postponed (maintainer needs more info)

Maybe there's some module that prevents redirect for you?
I got it work fine

donSchoe’s picture

No, wait, I dont get it.

I thought the logouttab_url is a URL where you get redirected to after you get logged out.
But you need this to point to a menu callback that logs out the user. This might be confusing.

If I want the user to redirect him to the loginscreen after logout, I need to either do 2 redirects (to /user/logout and then /user) or log out the user and after that do the redirect.

My patch does that exactly. Not sure what your intention was by setting a variable logouttab_url, if that only works for /user/logout. (Changing this variable kinda breaks the modules scope to log out the user.)

And in addition, if you are logged out, you will get an "access denied" error after this redirect to /user/logout. Because you cant log out if you are logged out already.

donSchoe’s picture

Status: Postponed (maintainer needs more info) » Needs review
andypost’s picture

Status: Needs review » Closed (works as designed)

@donSchoe I get you idea about redirect url, but this out of scope for the module.
The purpose of the module is to allow user to logout via tab.
If you need to redirect user after logout then you need different module

donSchoe’s picture

Okay, no problem.

I created my own submodule for this. I was just confused about the logouttab_url variable :-)