You are here

function drupal_auth in Drupal 5

Same name and namespace in other branches
  1. 4 modules/drupal.module \drupal_auth()

Implementation of hook_auth().

File

modules/drupal/drupal.module, line 313
Lets users log in using a Drupal ID and can notify a central server about your site.

Code

function drupal_auth($username, $password, $server = FALSE) {
  if (variable_get('drupal_authentication_service', 0)) {
    if (!$server) {
      $server = variable_get('drupal_default_da_server', '');
    }
    else {
      if (variable_get('drupal_default_da_server_only', 0)) {
        if (variable_get('drupal_default_da_server', '') != $server) {
          return;
        }
      }
    }
    if (!empty($server)) {
      $result = xmlrpc("http://{$server}/xmlrpc.php", 'drupal.login', $username, $password);
      if ($result === FALSE) {
        drupal_set_message(t('Error %code: %message', array(
          '%code' => xmlrpc_errno(),
          '%message' => xmlrpc_error_msg(),
        )), 'error');
      }
      else {
        return $result;
      }
    }
  }
}