You are here

function samlauth_check_saml_user in SAML Authentication 7

Same name and namespace in other branches
  1. 8.3 samlauth.module \samlauth_check_saml_user()
  2. 8 samlauth.module \samlauth_check_saml_user()
  3. 8.2 samlauth.module \samlauth_check_saml_user()
  4. 4.x samlauth.module \samlauth_check_saml_user()

Validation callback for SAML users logging in through the normal login form.

1 string reference to 'samlauth_check_saml_user'
samlauth_login_form_alter in ./samlauth.module
Common callback for user_login_block / user_login / user_pass.

File

./samlauth.module, line 126
Provides SAML authentication capabilities.

Code

function samlauth_check_saml_user($form, $form_state) {
  if (!variable_get('samlauth_drupal_saml_login', FALSE)) {
    if (form_get_errors()) {

      // If previous validation functions have already failed (name/pw incorrect
      // or blocked), bail out so we don't disclose any details about a user that
      // otherwise wouldn't be authenticated.
      return;
    }
    $account = user_load_by_name($form_state['values']['name']);
    if (!$account) {
      $account = user_load_by_mail($form_state['values']['name']);
    }
    if (!$account) {
      form_set_error('name', t('Could not load user to do a validation check.'));
    }
    else {
      $saml_id = samlauth_find_unique_id_by_user_id($account->uid);
      if ($saml_id !== FALSE) {
        form_set_error('name', t('SAML users must sign in with SSO.'));
      }
    }
  }
}