function fbconnect_login_autoconnect_form_submit in Facebook Connect 8.2
Same name and namespace in other branches
- 7.2 fbconnect_login/fbconnect_login.module \fbconnect_login_autoconnect_form_submit()
Submit handler for autoconnect form.
File
- fbconnect_login/
fbconnect_login.module, line 534 - Login functionality for Facebook Connect module
Code
function fbconnect_login_autoconnect_form_submit($form, &$form_state) {
$fbuid = fbconnect_get_fbuid();
if (!$fbuid) {
$error_msg = 'fbconnect_login_autoconnect_form_submit has been called without valid Facebook session. Check your Application Secret on fbconnect settings page';
watchdog('fbconnect', $error_msg, array(), WATCHDOG_ALERT, l(t('configure'), 'admin/config/people/fbconnect'));
return;
}
if (user_is_anonymous()) {
$uid = _is_fbconnect_user($fbuid);
$data = fbconnect_get_user_info(array(
'name',
'email',
));
if ($uid) {
$form_state['values']['uid'] = $uid;
}
$form_state['values']['fbuid'] = $fbuid;
if (!$uid) {
if (variable_get('fbconnect_reg_options', 0) == 1) {
if ($uid_from_email = _email_already_exist($data['email'])) {
// Connect Facebook to the existing account, and login the user.
fbconnect_login_register($uid_from_email, $data['id']);
$form_state['uid'] = $uid_from_email;
user_login_submit($form, $form_state);
}
else {
$form_state['redirect'] = array(
'fbconnect/authorize',
drupal_get_destination(),
);
}
}
else {
$form_state['redirect'] = array(
'fbconnect/authorize/prompt',
drupal_get_destination(),
);
}
// #805846 : No linking with FB page appears, when "destination" variable exist in url
unset($_GET['destination']);
}
elseif ($uid) {
$account = user_load($uid);
//user_external_login($account);
$form_state['uid'] = $uid;
user_login_submit(array(), $form_state);
module_invoke('rules', 'invoke_event', 'fbconnect_user_login', $account);
}
}
else {
fbconnect_login_redirect_submit($form, $form_state);
}
}