function user_pass_rehash
Same name and namespace in other branches
- 11.x core/modules/user/user.module \user_pass_rehash()
- 10 core/modules/user/user.module \user_pass_rehash()
- 9 core/modules/user/user.module \user_pass_rehash()
- 8.9.x core/modules/user/user.module \user_pass_rehash()
- 7.x modules/user/user.module \user_pass_rehash()
Creates a unique hash value for use in time-dependent per-user URLs.
This hash is normally used to build a unique and secure URL that is sent to the user by email for purposes such as resetting the user's password. In order to validate the URL, the same hash can be generated again, from the same information, and compared to the hash value from the URL. The hash contains the time stamp, the user's last login time, the numeric user ID, and the user's email address. For a usage example, see \Drupal\user\OneTimeAuthentication::generateCancelConfirmUrl() and \Drupal\user\Controller\UserController::confirmCancel().
Parameters
\Drupal\user\UserInterface $account: An object containing the user account.
int $timestamp: A UNIX timestamp, typically \Drupal::time()->getRequestTime().
Return value
string A string that is safe for use in URLs and SQL statements.
Deprecated
in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal\user\OneTimeAuthentication::generateHmac() instead.
See also
https://www.drupal.org/node/3581062
1 call to user_pass_rehash()
- UserPassRehashTest::testUniqueHashNoPasswordValue in core/
modules/ user/ tests/ src/ Kernel/ UserPassRehashTest.php - Tests uniqueness of hashes when no password is set.
File
-
core/
modules/ user/ user.module, line 186
Code
function user_pass_rehash(UserInterface $account, $timestamp) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal\\user\\OneTimeAuthentication::generateHmac() instead. See https://www.drupal.org/node/3581062', E_USER_DEPRECATED);
return \Drupal::service(OneTimeAuthentication::class)->generateHmac($account, $timestamp);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.