Hello,

After I click on logout (while logged in with fbconnect) I am taken to facebook.com. Looks like an error.

Comments

jim_at_miramontes’s picture

Subscribe. I've seen this too, but not all the time -- it's pretty random.

TahitiPetey’s picture

If you look at fb_user.module, you'll see:

function fb_user_user_logout($account) {
  global $user, $_fb_app;

  if (fb_facebook_user() &&
      fb_api_check_session($GLOBALS['_fb'])) {
    // Log out of facebook, as well as Drupal. Note that code in
    // fb_connect.js and fb_canvas.js attempts to call FB.logout. However,
    // that code is not reached if the user types "/logout" directly into
    // the browser URL. Also, a sometimes-occuring bug in firefox prevents
    // FB.logout from always succeeding.

    // Figure out where to send the user.
    if (isset($_REQUEST['destination'])) {
      $next_url = url($_REQUEST['destination'], array('absolute' => TRUE, 'fb_canvas' => fb_is_canvas()));
      // Unset desination so drupal_goto() below does what we need it to do.
      unset($_REQUEST['destination']);
    }
    else {
      $next_url = url('<front>', array('absolute' => TRUE, 'fb_canvas' => fb_is_canvas()));
    }
    $logout_url = $GLOBALS['_fb']->getLogoutUrl(array(
                    'next' => $next_url,
                    'cancel_url' => $next_url,
                  ));
    drupal_goto($logout_url);
  }
}

So it seems like an obscure FF bug that happens to trigger this behaviour.

Also correlates to my anecdotal observations. I use Opera/Chrome/IE9 and have never seen this behaviour once.

An easy but extremely hacky fix would be to replace drupal_goto($logout_url) with drupal_goto(url(')) if you simply want the user to be redirected to the front page after log out.

jim_at_miramontes’s picture

Interesting suggestion, @TahitiPetey -- I'll give it a try. (This code has been moved into a logout handler in fb_user_user in 6.x-3.1, but the logic holds.)

Dave Cohen’s picture

The modules try two different ways to log you out of facebook. The code you're looking at applies when a user visits the /logout url directly.

Usually when the click the logout link, the javascript in FB_Connect.logoutHandler() is expected to log them out of facebook. So in the code you're looking at, fb_facebook_user() should return FALSE.

j_ten_man’s picture

Seeing this behavior consistently between all browsers on our site. Anyone else have any ideas?

Dave Cohen’s picture

I think something changed recently in facebook's behavior.

The idea behind this code is to forward the user to facebook's logout URL, with the next=... parameter which is supposed to send them back to the website. Without this, if they are still logged into facebook fb_user.module will detect that and keep them logged in. In other words without this there would be no logging out.

It seems recent changes to facebook SDK have broken this and also the javascript FB.logout() call. Annoying.

edgarpe’s picture

Is there a way to change the logout behaviour, and keep the user logged into facebook after logging out from drupal site? I think it is safe to say, this feature is pretty annoying for users.

jim_at_miramontes’s picture

There's more on this decoupling issue at http://drupal.org/node/1339140 ...

edgarpe’s picture

OK, I realized that Drupal for Facebook is much more a Single Sign On service, than a simple User Authentication mechanism. And this is something very cool. I like this a lot.

If you run your site on multiple hostnames or domains Drupal for Facebook "magically" logs in Facebook connect users. But every SSO have to sign in a logged out user, so if you log out from drupal without logging out from FB, the drupal for facebook will sign you in again.

Forget #7, keep it this way :)