Community Documentation

hook_auth

5 authentication.php hook_auth($username, $password, $server)

Verify authentication of a user.

The _auth hook is the heart of any authentication module. This function is called whenever a user is attempting to log in using your authentication module. The module uses this information to allow or deny access to the site.

Parameters

$username: The substring before the final '@' character in the username field.

$password: The whole string submitted by the user in the password field.

$server: The substring after the final '@' symbol in the username field.

Return value

For successful authentications, this function returns TRUE. Otherwise, it returns FALSE.

Related topics

File

developer/hooks/authentication.php, line 38
These hooks are defined by authentication modules, modules that define ways users can log on using accounts from other sites and servers.

Code

<?php
function hook_auth($username, $password, $server) {
  $message = new xmlrpcmsg('drupal.login', array(new xmlrpcval($username, 
    'string'), new xmlrpcval($password, 'string')));

  $client = new xmlrpc_client('/xmlrpc.php', $server, 80);
  $result = $client->send($message, 5);
  if ($result && !$result->faultCode()) {
    $value = $result->value();
    $login = $value->scalarval();
  }

  return $login;
}
?>
Login or register to post comments