function simple_fb_connect_login_user in Simple FB Connect 7.2
Logs the given user in.
Parameters
$drupal_user: A Drupal user object.
Return value
bool True if login was successful. False if login was blocked.
1 call to simple_fb_connect_login_user()
- simple_fb_connect_return_from_fb in ./
simple_fb_connect.module - Page callback for /user/simple-fb-connect/return.
File
- ./
simple_fb_connect.module, line 800 - Simple Facebook Login Module for Drupal Sites.
Code
function simple_fb_connect_login_user($drupal_user) {
// Prevent admin login if defined in module settings.
if (simple_fb_connect_login_disabled_for_admin($drupal_user)) {
drupal_set_message(t('FB login is disabled for site administrator. Please login with your local user account.'), 'error');
return FALSE;
}
// Prevent login if user has one of the roles defined in module settings.
if (simple_fb_connect_login_disabled_by_role($drupal_user)) {
drupal_set_message(t('FB login is disabled for your role. Please login with your local user account.'), 'error');
return FALSE;
}
// Check that the account is active.
if ($drupal_user->status) {
// Do the actual login.
$form_state['uid'] = $drupal_user->uid;
user_login_submit(array(), $form_state);
// Invoke a login event if Rules module is enabled.
if (module_exists('rules')) {
rules_invoke_event('simple_fb_connect_login', $drupal_user);
}
// Invoke a login event if some module implements hook_simple_fb_connect_login.
module_invoke_all('simple_fb_connect_login', $drupal_user);
// If Boost module is used, we need to add DRUPAL_UID cookie.
// If this cookie is set, Boost will not serve cached pages to the user.
// user/simple-fb-connect/* must also be added to Boost "cache all pages except those listed".
if (module_exists('boost')) {
boost_set_cookie($drupal_user->uid);
}
return TRUE;
}
// If we are still here, account is blocked.
drupal_set_message(t('You could not be logged in because your account %username is not active.', array(
'%username' => $drupal_user->name,
)), 'warning');
watchdog('simple_fb_connect', 'FB login for user %user prevented. Account is blocked.', array(
'%user' => $drupal_user->name,
), WATCHDOG_WARNING);
return FALSE;
}