diff --git a/src/Commands/core/LoginCommands.php b/src/Commands/core/LoginCommands.php index 98c7840d68..370732bd10 100644 --- a/src/Commands/core/LoginCommands.php +++ b/src/Commands/core/LoginCommands.php @@ -7,6 +7,7 @@ use Drush\Exec\ExecTrait; use Consolidation\SiteAlias\SiteAliasManagerAwareInterface; use Consolidation\SiteAlias\SiteAliasManagerAwareTrait; +use Drupal\Core\Url; class LoginCommands extends DrushCommands implements SiteAliasManagerAwareInterface { @@ -71,10 +72,20 @@ public function login($path = '', $options = ['name' => null, 'uid' => null, 'ma $account = User::load(1); } - $link = user_pass_reset_url($account). '/login'; - if ($path) { - $link .= '?destination=' . $path; - } + $timestamp = \Drupal::time()->getRequestTime(); + $link = Url::fromRoute( + 'user.reset.login', + [ + 'uid' => $account->id(), + 'timestamp' => $timestamp, + 'hash' => user_pass_rehash($account, $timestamp), + ], + [ + 'absolute' => true, + 'query' => $path ? ['destination' => $path] : [], + 'language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()), + ] + )->toString(); } $port = $options['redirect-port']; $this->startBrowser($link, false, $port, $options['browser']);