function user_pass_reset_url in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/user.module \user_pass_reset_url()
Generates a unique URL for a user to login and reset their password.
Parameters
\Drupal\user\UserInterface $account: An object containing the user account.
array $options: (optional) A keyed array of settings. Supported options are:
- langcode: A language code to be used when generating locale-sensitive URLs. If langcode is NULL the users preferred language is used.
Return value
string A unique URL that provides a one-time log in for the user, from which they can change their password.
4 calls to user_pass_reset_url()
- UserPasswordResetTest::testResetImpersonation in core/
modules/ user/ src/ Tests/ UserPasswordResetTest.php - Make sure that users cannot forge password reset URLs of other users.
- UserRegistrationTest::testRegistrationWithEmailVerification in core/
modules/ user/ src/ Tests/ UserRegistrationTest.php - UserTokenReplaceTest::testUserTokenReplacement in core/
modules/ user/ src/ Tests/ UserTokenReplaceTest.php - Creates a user, then tests the tokens generated from it.
- user_mail_tokens in core/
modules/ user/ user.module - Token callback to add unsafe tokens for user mails.
File
- core/
modules/ user/ user.module, line 579 - Enables the user registration and login system.
Code
function user_pass_reset_url($account, $options = array()) {
$timestamp = REQUEST_TIME;
$langcode = isset($options['langcode']) ? $options['langcode'] : $account
->getPreferredLangcode();
return \Drupal::url('user.reset', array(
'uid' => $account
->id(),
'timestamp' => $timestamp,
'hash' => user_pass_rehash($account, $timestamp),
), array(
'absolute' => TRUE,
'language' => \Drupal::languageManager()
->getLanguage($langcode),
));
}