Mercurial > hg > isophonics-drupal-site
diff core/modules/user/src/Controller/UserController.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children | af1871eacc83 |
line wrap: on
line diff
--- a/core/modules/user/src/Controller/UserController.php Tue Jul 10 15:07:59 2018 +0100 +++ b/core/modules/user/src/Controller/UserController.php Thu Feb 28 13:21:36 2019 +0000 @@ -120,12 +120,17 @@ else { /** @var \Drupal\user\UserInterface $reset_link_user */ if ($reset_link_user = $this->userStorage->load($uid)) { - drupal_set_message($this->t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href=":logout">log out</a> and try using the link again.', - ['%other_user' => $account->getUsername(), '%resetting_user' => $reset_link_user->getUsername(), ':logout' => $this->url('user.logout')]), 'warning'); + $this->messenger() + ->addWarning($this->t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href=":logout">log out</a> and try using the link again.', + [ + '%other_user' => $account->getUsername(), + '%resetting_user' => $reset_link_user->getUsername(), + ':logout' => $this->url('user.logout'), + ])); } else { // Invalid one-time link specifies an unknown user. - drupal_set_message($this->t('The one-time login link you clicked is invalid.'), 'error'); + $this->messenger()->addError($this->t('The one-time login link you clicked is invalid.')); } return $this->redirect('<front>'); } @@ -218,13 +223,13 @@ $timeout = $this->config('user.settings')->get('password_reset_timeout'); // No time out for first time login. if ($user->getLastLoginTime() && $current - $timestamp > $timeout) { - drupal_set_message($this->t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'), 'error'); + $this->messenger()->addError($this->t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.')); return $this->redirect('user.pass'); } elseif ($user->isAuthenticated() && ($timestamp >= $user->getLastLoginTime()) && ($timestamp <= $current) && Crypt::hashEquals($hash, user_pass_rehash($user, $timestamp))) { user_login_finalize($user); $this->logger->notice('User %name used one-time login link at time %timestamp.', ['%name' => $user->getDisplayName(), '%timestamp' => $timestamp]); - drupal_set_message($this->t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.')); + $this->messenger()->addStatus($this->t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.')); // Let the user's password be changed without the current password // check. $token = Crypt::randomBytesBase64(55); @@ -239,7 +244,7 @@ ); } - drupal_set_message($this->t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'), 'error'); + $this->messenger()->addError($this->t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.')); return $this->redirect('user.pass'); } @@ -268,7 +273,7 @@ * NULL. */ public function userTitle(UserInterface $user = NULL) { - return $user ? ['#markup' => $user->getUsername(), '#allowed_tags' => Xss::getHtmlTagList()] : ''; + return $user ? ['#markup' => $user->getDisplayName(), '#allowed_tags' => Xss::getHtmlTagList()] : ''; } /** @@ -315,7 +320,7 @@ return batch_process('<front>'); } else { - drupal_set_message(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'error'); + $this->messenger()->addError($this->t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.')); return $this->redirect('entity.user.cancel_form', ['user' => $user->id()], ['absolute' => TRUE]); } }