function user_pass_rehash in Drupal 6
Same name and namespace in other branches
- 8 core/modules/user/user.module \user_pass_rehash()
- 4 modules/user.module \user_pass_rehash()
- 5 modules/user/user.module \user_pass_rehash()
- 7 modules/user/user.module \user_pass_rehash()
- 9 core/modules/user/user.module \user_pass_rehash()
- 10 core/modules/user/user.module \user_pass_rehash()
2 calls to user_pass_rehash()
- user_pass_reset in modules/
user/ user.pages.inc - Menu callback; process one time login link and redirects to the user page on success.
- user_pass_reset_url in modules/
user/ user.module - Generates a unique URL for a user to login and reset their password.
File
- modules/
user/ user.module, line 1497 - Enables the user registration and login system.
Code
function user_pass_rehash($password, $timestamp, $login, $uid) {
// Backwards compatibility: Try to determine a $uid if one was not passed.
// (Since $uid is a required parameter to this function, a PHP warning will
// be generated if it's not provided, which is an indication that the calling
// code should be updated. But the code below will try to generate a correct
// hash in the meantime.)
if (!isset($uid)) {
$uids = array();
$result = db_query_range("SELECT uid FROM {users} WHERE pass = '%s' AND login = '%s' AND uid > 0", $password, $login, 0, 2);
while ($row = db_fetch_array($result)) {
$uids[] = $row['uid'];
}
// If exactly one user account matches the provided password and login
// timestamp, proceed with that $uid.
if (count($uids) == 1) {
$uid = reset($uids);
}
else {
return drupal_random_key();
}
}
return drupal_hmac_base64($timestamp . $login . $uid, drupal_get_private_key() . $password);
}