You are here

function _simplesamlphp_auth_get_mail in simpleSAMLphp Authentication 7.3

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 simplesamlphp_auth.module \_simplesamlphp_auth_get_mail()
  4. 7.2 simplesamlphp_auth.module \_simplesamlphp_auth_get_mail()

Gets the mail attribute.

Return value

string The mail attribute.

1 call to _simplesamlphp_auth_get_mail()
_simplesaml_auth_user_update in ./simplesamlphp_auth.inc
Updates a SAML-authenticated user's account with current username and email.

File

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