You are here

function shib_auth_custom_username in Shibboleth Authentication 6.4

Same name and namespace in other branches
  1. 7.4 shib_auth.module \shib_auth_custom_username()

User Data Customization function - USERNAME This function handles the username customization process @uname the username got from IdP @custom_uname the customized username @umail_single the e-mail address received from IdP

2 calls to shib_auth_custom_username()
shib_auth_custom_form in ./shib_auth.module
If any customization or consent option is enabled, the custom form will show up before registering and forces the user to accept user consent and define username and/or e-mail address (prefilling fields with the data coming from the…
shib_auth_custom_mail in ./shib_auth.module
User Data Customization function - MAIL This function handles the mail customization process @uname the username got from IdP @custom_uname the customized username @custom_mail the costumized e-mail address

File

./shib_auth.module, line 440
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(filter_xss($error));
  }
  else {

    //check if username already exists
    $un_already_used_query = db_query("SELECT * FROM {users} WHERE name='%s'", $custom_username);
    $un_already_used = db_fetch_object($un_already_used_query);
    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);
    }
  }
}