You are here

function user_pass_validate in Drupal 6

Same name and namespace in other branches
  1. 4 modules/user.module \user_pass_validate()
  2. 5 modules/user/user.module \user_pass_validate()
  3. 7 modules/user/user.pages.inc \user_pass_validate()

File

modules/user/user.pages.inc, line 43
User page callback file for the user module.

Code

function user_pass_validate($form, &$form_state) {
  $name = trim($form_state['values']['name']);

  // Try to load by email.
  $account = user_load(array(
    'mail' => $name,
    'status' => 1,
  ));
  if (!$account) {

    // No success, try to load by name.
    $account = user_load(array(
      'name' => $name,
      'status' => 1,
    ));
  }
  if ($account) {

    // Blocked accounts cannot request a new password,
    // check provided username and email against access rules.
    if (drupal_is_denied('user', $account->name) || drupal_is_denied('mail', $account->mail)) {
      form_set_error('name', t('%name is not allowed to request a new password.', array(
        '%name' => $name,
      )));
    }
  }
  if (isset($account->uid)) {
    form_set_value(array(
      '#parents' => array(
        'account',
      ),
    ), $account, $form_state);
  }
  else {
    form_set_error('name', t('Sorry, %name is not recognized as a user name or an e-mail address.', array(
      '%name' => $name,
    )));
  }
}