function user_pass_rehash
Same name in other branches
- 7.x 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()
- 11.x core/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 user_cancel_url() and \Drupal\user\Controller\UserController::confirmCancel().
Parameters
\Drupal\user\UserInterface $account: An object containing the user account.
int $timestamp: A UNIX timestamp, typically REQUEST_TIME.
Return value
string A string that is safe for use in URLs and SQL statements.
11 calls to user_pass_rehash()
- UserCancelTest::testUserAnonymize in core/
modules/ user/ tests/ src/ Functional/ UserCancelTest.php - Delete account and anonymize all content.
- UserCancelTest::testUserAnonymizeBatch in core/
modules/ user/ tests/ src/ Functional/ UserCancelTest.php - Delete account and anonymize all content using a batch process.
- UserCancelTest::testUserBlock in core/
modules/ user/ tests/ src/ Functional/ UserCancelTest.php - Disable account and keep all content.
- UserCancelTest::testUserBlockUnpublish in core/
modules/ user/ tests/ src/ Functional/ UserCancelTest.php - Disable account and unpublish all content.
- UserCancelTest::testUserCancelInvalid in core/
modules/ user/ tests/ src/ Functional/ UserCancelTest.php - Attempt invalid account cancellations.
File
-
core/
modules/ user/ user.module, line 701
Code
function user_pass_rehash(UserInterface $account, $timestamp) {
$data = $timestamp;
$data .= $account->getLastLoginTime();
$data .= $account->id();
$data .= $account->getEmail();
return Crypt::hmacBase64($data, Settings::getHashSalt() . $account->getPassword());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.