You are here

function userone_authenticate in User One 6

Return value

True if User One handled authentication whether it was successful or not so it is not handled again by user_authenticate().

1 call to userone_authenticate()
userone_login_authenticate_validate in ./userone.module
Replace core's user_login_authenticate_validate()

File

./userone.module, line 135
User One module.

Code

function userone_authenticate($form_values) {
  global $user;
  if ($userone_name = variable_get('userone_name', '')) {
    $userone = user_load(1);
    if ($form_values['name'] == $userone_name) {
      if (md5($form_values['pass']) == $userone->pass) {
        if (userone_check_ip()) {
          $user = $userone;
          user_authenticate_finalize($form_values);
          watchdog('userone', 'Session opened for user one account.');
        }
        else {
          watchdog('userone', 'Login attempt failed for user one due to unmatching IP address.');
        }
      }
      else {
        watchdog('userone', 'Login attempt failed for user one with User One login (%user).', array(
          '%user' => $form_values['name'],
        ));
      }
      return TRUE;
    }
    elseif ($form_values['name'] == $userone->name) {
      if (md5($form_values['pass']) == $userone->pass) {
        watchdog('userone', 'Login attempt failed for user one with Drupal username (%user) and correct password.', array(
          '%user' => $form_values['name'],
        ));
      }
      else {
        watchdog('userone', 'Login attempt failed for user one with Drupal username (%user) and wrong password.', array(
          '%user' => $form_values['name'],
        ));
      }
      return TRUE;
    }
  }
  return FALSE;
}