You are here

function _simplesaml_auth_user_login in simpleSAMLphp Authentication 7.3

Logs an SAML-authenticated user into Drupal.

Parameters

object $ext_user: The Drupal user object to be logged in.

Throws

Exception

2 calls to _simplesaml_auth_user_login()
simplesamlphp_auth_user_insert in ./simplesamlphp_auth.module
Implements hook_user_insert().
_simplesaml_auth_login_register in ./simplesamlphp_auth.inc
Performs login and/or register actions for SAML authenticated users.

File

./simplesamlphp_auth.inc, line 200
Contains non-hook implementations.

Code

function _simplesaml_auth_user_login($ext_user) {
  global $user;

  // See if we're supposed to re-evaluate role assignments.
  if (variable_get('simplesamlphp_auth_roleevaleverytime', 0)) {

    // Populate roles based on configuration setting.
    if (variable_get('simplesamlphp_auth_debug', 0)) {
      watchdog('simplesamlphp_auth', 'User already registered [%authname] updating roles.', array(
        '%authname' => $ext_user->name,
      ), WATCHDOG_DEBUG);
    }
    $roles = _simplesamlphp_auth_rolepopulation(variable_get('simplesamlphp_auth_rolepopulation', ''));
    $userinfo = array(
      'roles' => $roles,
    );

    // Save the updated roles and populate the user object.
    $user = user_save($ext_user, $userinfo);
  }
  else {

    // No need to evaluate roles, populate the user object.
    $user = $ext_user;
  }
  if (module_exists('rules')) {
    rules_invoke_all('simplesamlphp_auth_rules_event_login', $user);
  }

  // Finalizing the login, calls hook_user op login.
  $edit = array();
  user_login_finalize($edit);
}