function shib_auth_custom_username in Shibboleth Authentication 7.4
Same name and namespace in other branches
- 6.4 shib_auth.module \shib_auth_custom_username()
User Data Customization function - USERNAME.
This function handles the username customization process.
Parameters
string $uname: The username got from IdP.
string $custom_username: The customized username.
string $umail_single: The first email address of the user from the IdP.
2 calls to shib_auth_custom_username()
- shib_auth_custom_form in ./
shib_auth.module - Displays custom form if either customization or consent options are enabled.
- shib_auth_custom_mail in ./
shib_auth.module - User Data Customization function - MAIL.
File
- ./
shib_auth.module, line 529 - Drupal Shibboleth authentication module.
Code
function shib_auth_custom_username($uname, $custom_username = '', $umail_single = '') {
// Validate it.
if ($error = user_validate_name($custom_username)) {
shib_auth_error($error);
}
else {
// Check if username already exists.
$un_already_used = db_select('users', 'c')
->fields('c')
->condition('name', $custom_username, '=')
->execute()
->fetchObject();
if ($un_already_used) {
shib_auth_error('Error saving user account. User name is already used.');
}
else {
shib_auth_save_authmap($uname, $custom_username, $umail_single);
}
}
}