function _connector_log_in in Connector 7
Same name and namespace in other branches
- 6 connector.module \_connector_log_in()
2 string references to '_connector_log_in'
- connector_connector_action in ./
connector.module - hook_connector_action in ./
connector.api.php - Define custom actions.
File
- ./
connector.module, line 401 - Connector module
Code
function _connector_log_in($connector_name, $cid = NULL, $consumer = NULL, $access_token = NULL, $request_token = NULL) {
global $user;
if (user_is_logged_in()) {
return TRUE;
}
$connector = _connector_get_connectors($connector_name);
if (!$connector) {
return FALSE;
}
//Fetch connector ID
if ($cid === NULL && isset($connector['id callback']) && is_callable($connector['id callback'])) {
$cid = call_user_func($connector['id callback'], $connector);
}
if ($cid !== NULL) {
$authname = $connector_name . '__' . $cid;
$account = user_external_load($authname);
if (!$account) {
// Return NULL and not FALSE so that we know we didn't find a user.
return NULL;
}
if ($account) {
if ($account->status) {
if (variable_get('user_email_verification', FALSE) && !$account->login) {
// User still needs to verify the emailaddress.
drupal_set_message(t('Your account is currently pending e-mail verification. You have receveid a email with further instructions. !link to start a new e-mail verification.', array(
'!link' => l('Request a new password', 'user/password'),
)), 'warning');
if (isset($connector['logout callback']) && is_callable($connector['logout callback'])) {
call_user_func($connector['logout callback'], $connector, $connection->cid);
}
}
else {
//Log in user
$form_state['uid'] = $account->uid;
user_login_submit(array(), $form_state);
return TRUE;
}
}
else {
drupal_set_message(t('Your account is currently pending approval by the site administrator.'), 'warning');
// why logout when account is pending? may be it is intentional.
if (isset($connector['logout callback']) && is_callable($connector['logout callback'])) {
call_user_func($connector['logout callback'], $connector, $connection->cid);
}
}
}
}
return FALSE;
}