You are here

function _simplesamlphp_auth_get_mail in simpleSAMLphp Authentication 7.2

Same name and namespace in other branches
  1. 6.3 simplesamlphp_auth.module \_simplesamlphp_auth_get_mail()
  2. 6.2 simplesamlphp_auth.module \_simplesamlphp_auth_get_mail()
  3. 7.3 simplesamlphp_auth.module \_simplesamlphp_auth_get_mail()
  4. 7 simplesamlphp_auth.module \_simplesamlphp_auth_get_mail()

Gets the mail attribute.

Return value

string The mail attribute.

1 call to _simplesamlphp_auth_get_mail()
simplesamlphp_auth_user_insert in ./simplesamlphp_auth.module
Implements hook_user_insert().

File

./simplesamlphp_auth.module, line 640
simpleSAMLphp authentication module for Drupal.

Code

function _simplesamlphp_auth_get_mail() {
  global $_simplesamlphp_auth_as;
  global $_simplesamlphp_auth_saml_attributes;
  $mail_address = '';

  // Check if valid local session exists..
  if ($_simplesamlphp_auth_as
    ->isAuthenticated()) {
    if (isset($_simplesamlphp_auth_saml_attributes[variable_get('simplesamlphp_auth_mailattr', 'mail')])) {
      $mail_address = $_simplesamlphp_auth_saml_attributes[variable_get('simplesamlphp_auth_mailattr', 'mail')][0];
    }
    else {
      throw new Exception(t('Error in simplesamlphp_auth.module: No valid mail attribute set.'));
    }
  }
  return $mail_address;
}