Error message
You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).function user_authenticate
Try to validate the user's login credentials locally.
Parameters
$name: User name to authenticate.
$password: A plain-text password, such as trimmed text from form values.
Return value
The user's uid on success, or FALSE on failure to authenticate.
1 call to user_authenticate()
- user_login_authenticate_validate in modules/
user/ user.module - A validate handler on the login form. Check supplied username/password against local users table. If successful, $form_state['uid'] is set to the matching user ID.
File
-
modules/
user/ user.module, line 2293
Code
function user_authenticate ($name, $password) {
$uid = FALSE;
if (!empty($name) && strlen (trim ($password)) > 0) {
$account = user_load_by_name ($name);
if ($account) {
// Allow alternate password hashing schemes.
require_once DRUPAL_ROOT . '/' . variable_get ('password_inc', 'includes/password.inc');
if (user_check_password ($password, $account)) {
// Successful authentication.
$uid = $account->uid;
// Update user to new password scheme if needed.
if (user_needs_new_hash ($account)) {
user_save ($account, array(
'pass' => $password,
));
}
}
}
}
return $uid;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.