You are here

function _fb_user_check_and_goto in Drupal for Facebook 7.3

Detect whether facebook indicates the user has changed. If so, redirect.

1 call to _fb_user_check_and_goto()
fb_user_page_alter in ./fb_user.module
Implements hook_page_alter().

File

./fb_user.module, line 291
This module manages relations between local Drupal user accounts and their accounts on facebook.com.

Code

function _fb_user_check_and_goto() {
  if (($fbu = fb_facebook_user()) && !fb_is_tab() && $fbu != fb_get_fbu($GLOBALS['user'])) {
    $uid = $GLOBALS['user']->uid;

    // Remember original uid.
    _fb_user_process_authorized_user();
    if ($uid != $GLOBALS['user']->uid) {

      // We've detected a change of user and started a new session.  Refresh page.
      if (!fb_controls(FB_USER_CONTROL_NO_REDIRECT)) {
        if (empty($REQUEST['_fb_user_fbu']) || $REQUEST['_fb_user_fbu'] != $fbu) {
          drupal_goto(request_path(), array(
            // Parameter avoids refresh loop when third-party cookies disabled on Safari.
            'query' => array(
              '_fb_user_fbu' => $fbu,
            ),
          ));
        }
      }
    }
  }
}