Revert "Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login link instead of user login form in BrowserTestBase tests"

This reverts commit b16714a919.
merge-requests/9515/head
nod_ 2024-09-07 01:00:08 +02:00
parent b16714a919
commit 80a680c5ca
No known key found for this signature in database
GPG Key ID: 76624892606FA197
5 changed files with 7 additions and 38 deletions

View File

@ -28,11 +28,6 @@ class LocaleTranslatedSchemaDefinitionTest extends BrowserTestBase {
*/ */
protected $defaultTheme = 'stark'; protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected bool $useOneTimeLoginLinks = FALSE;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -169,13 +169,7 @@ class UserLoginTest extends BrowserTestBase {
$this->assertTrue($password_hasher->needsRehash($account->getPassword())); $this->assertTrue($password_hasher->needsRehash($account->getPassword()));
$account->passRaw = $password; $account->passRaw = $password;
$this->drupalGet('user/login'); $this->drupalLogin($account);
$edit = [
'name' => $account->getAccountName(),
'pass' => $account->passRaw,
];
$this->submitForm($edit, 'Log in');
// Load the stored user, which should have a different password hash now. // Load the stored user, which should have a different password hash now.
$user_storage->resetCache([$account->id()]); $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id()); $account = $user_storage->load($account->id());

View File

@ -27,11 +27,6 @@ class UserTokenReplaceTest extends BrowserTestBase {
*/ */
protected $defaultTheme = 'stark'; protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected bool $useOneTimeLoginLinks = FALSE;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -521,7 +521,7 @@ function user_user_logout(AccountInterface $account) {
* they can change their password. * they can change their password.
*/ */
function user_pass_reset_url($account, $options = []) { function user_pass_reset_url($account, $options = []) {
$timestamp = \Drupal::time()->getCurrentTime(); $timestamp = \Drupal::time()->getRequestTime();
$langcode = $options['langcode'] ?? $account->getPreferredLangcode(); $langcode = $options['langcode'] ?? $account->getPreferredLangcode();
return Url::fromRoute('user.reset', return Url::fromRoute('user.reset',
[ [

View File

@ -28,11 +28,6 @@ trait UiHelperTrait {
*/ */
protected $loggedInUser = FALSE; protected $loggedInUser = FALSE;
/**
* Use one-time login links instead of submitting the login form.
*/
protected bool $useOneTimeLoginLinks = TRUE;
/** /**
* The number of meta refresh redirects to follow, or NULL if unlimited. * The number of meta refresh redirects to follow, or NULL if unlimited.
* *
@ -161,21 +156,11 @@ trait UiHelperTrait {
$this->drupalLogout(); $this->drupalLogout();
} }
if ($this->useOneTimeLoginLinks) { $this->drupalGet(Url::fromRoute('user.login'));
// Reload to get latest login timestamp. $this->submitForm([
$storage = \Drupal::entityTypeManager()->getStorage('user'); 'name' => $account->getAccountName(),
/** @var \Drupal\user\UserInterface $accountUnchanged */ 'pass' => $account->passRaw,
$accountUnchanged = $storage->loadUnchanged($account->id()); ], 'Log in');
$login = user_pass_reset_url($accountUnchanged) . '/login?destination=user/' . $account->id();
$this->drupalGet($login);
}
else {
$this->drupalGet(Url::fromRoute('user.login'));
$this->submitForm([
'name' => $account->getAccountName(),
'pass' => $account->passRaw,
], 'Log in');
}
// @see ::drupalUserIsLoggedIn() // @see ::drupalUserIsLoggedIn()
$account->sessionId = $this->getSession()->getCookie(\Drupal::service('session_configuration')->getOptions(\Drupal::request())['name']); $account->sessionId = $this->getSession()->getCookie(\Drupal::service('session_configuration')->getOptions(\Drupal::request())['name']);