You are here

function _simplesamlphp_auth_get_mail in simpleSAMLphp Authentication 6.2

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

Gets the mail attribute.

Return value

The mail attribute.

1 call to _simplesamlphp_auth_get_mail()
simplesamlphp_auth_user in ./simplesamlphp_auth.module
Implementation of hook_user().

File

./simplesamlphp_auth.module, line 675
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;
}