function _simplesaml_auth_user_update in simpleSAMLphp Authentication 7.3
Updates a SAML-authenticated user's account with current username and email.
Parameters
object $account: The user account object to update.
1 call to _simplesaml_auth_user_update()
- simplesamlphp_auth_user_insert in ./
simplesamlphp_auth.module - Implements hook_user_insert().
File
- ./
simplesamlphp_auth.inc, line 160 - Contains non-hook implementations.
Code
function _simplesaml_auth_user_update($account) {
if (variable_get('simplesamlphp_auth_debug', 0)) {
watchdog('simplesamlphp_auth', 'Updating username [%acctname]', array(
'%acctname' => $account->name,
), WATCHDOG_DEBUG);
}
db_update('users')
->fields(array(
'name' => $account->name,
))
->condition('uid', $account->uid)
->execute();
// Get mail from default attribute.
try {
$mail_address = _simplesamlphp_auth_get_mail();
} catch (Exception $e) {
drupal_set_message(t('Your e-mail address was not provided by your identity provider (IDP).'), "error");
watchdog('simplesamlphp_auth', $e
->getMessage(), NULL, WATCHDOG_CRITICAL);
}
if (variable_get('simplesamlphp_auth_debug', 0)) {
watchdog('simplesamlphp_auth', 'Updating mail [%mailaddr]', array(
'%mailaddr' => $mail_address,
), WATCHDOG_DEBUG);
}
if (!empty($mail_address)) {
db_update('users')
->fields(array(
'mail' => $mail_address,
))
->condition('uid', $account->uid)
->execute();
}
}