function fbconnect_login_unregister in Facebook Connect 7.2
Same name and namespace in other branches
- 8.2 fbconnect_login/fbconnect_login.module \fbconnect_login_unregister()
Unlink Facebook account from user account.
1 call to fbconnect_login_unregister()
- fbconnect_login_user_settings_form_submit in fbconnect_login/
fbconnect_login.pages.inc - Handle post-validation user_settingsForm submission.
File
- fbconnect_login/
fbconnect_login.module, line 479 - Login functionality for Facebook Connect module
Code
function fbconnect_login_unregister($fbuid) {
if (!($fb_session = facebook_client_session())) {
return FALSE;
}
if ($fbuid && ($uid = _is_fbconnect_user($fbuid))) {
try {
try {
$request = (new FacebookRequest($fb_session, 'DELETE', '/me/permissions'))
->execute();
} catch (Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
throw $e;
}
} catch (Exception $e) {
watchdog('fbconnect', 'Exception thrown while using fbconnect_unregister: @code', array(
'@code' => $e
->getMessage(),
), WATCHDOG_ERROR);
}
db_delete('fbconnect_users')
->condition('fbuid', $fbuid)
->execute();
$account = user_load($uid);
$account->fbuid = NULL;
user_save($account, array(
'fbuid' => NULL,
));
module_invoke('rules', 'invoke_event', 'fbconnect_user_unregistered', $account);
watchdog('fbconnect', 'User authorization is revoked (@fbuid)', array(
'@fbuid' => $fbuid,
), WATCHDOG_NOTICE, l(t('edit'), "user/{$uid}/edit/fbconnect"));
return TRUE;
}
$msg = __FUNCTION__ . ' is called with wrong $fbuid(@fbuid) argument ';
watchdog('fbconnect', $msg, array(
'@fbuid' => $fbuid,
), WATCHDOG_ERROR);
return FALSE;
}