diff --git a/core/modules/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php index 1941dbf..5997735 100644 --- a/core/modules/user/src/Controller/UserController.php +++ b/core/modules/user/src/Controller/UserController.php @@ -40,6 +40,8 @@ class UserController extends ControllerBase { * * @param \Drupal\Core\Datetime\Date $date * The date formatting service. + * @param \Drupal\user\UserStorageInterface $user_storage + * The user storage. */ public function __construct(Date $date, UserStorageInterface $user_storage) { $this->date = $date; diff --git a/core/modules/user/src/Form/UserPasswordResetForm.php b/core/modules/user/src/Form/UserPasswordResetForm.php index 3b8cd98..ba7c121 100644 --- a/core/modules/user/src/Form/UserPasswordResetForm.php +++ b/core/modules/user/src/Form/UserPasswordResetForm.php @@ -10,6 +10,8 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Component\Utility\Crypt; use Drupal\Core\Form\FormBase; +use Psr\Log\LoggerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Form controller for the user password forms. @@ -17,6 +19,32 @@ class UserPasswordResetForm extends FormBase { /** + * A logger instance. + * + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + + /** + * Constructs a new UserPasswordResetForm. + * + * @param \Psr\Log\LoggerInterface $logger + * A logger instance. + */ + public function __construct(LoggerInterface $logger) { + $this->logger = $logger; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('logger.factory')->get('user') + ); + } + + /** * {@inheritdoc} */ public function getFormID() { @@ -26,6 +54,10 @@ public function getFormID() { /** * {@inheritdoc} * + * @param array $form + * An associative array containing the structure of the form. + * @param array $form_state + * An associative array containing the current state of the form. * @param \Drupal\Core\Session\AccountInterface $user * User requesting reset. * @param string $expiration_date @@ -56,7 +88,10 @@ public function buildForm(array $form, array &$form_state, AccountInterface $use ); $form['help'] = array('#markup' => '

' . $this->t('This login can be used only once.') . '

'); $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Log in')); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => $this->t('Log in'), + ); return $form; } @@ -64,9 +99,10 @@ public function buildForm(array $form, array &$form_state, AccountInterface $use * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { + /** @var $user \Drupal\user\UserInterface */ $user = $form_state['values']['user']; user_login_finalize($user); - watchdog('user', 'User %name used one-time login link at time %timestamp.', array('%name' => $user->getUsername(), '%timestamp' => $form_state['values']['timestamp'])); + $this->logger->notice('User %name used one-time login link at time %timestamp.', array('%name' => $user->getUsername(), '%timestamp' => $form_state['values']['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.')); // Let the user's password be changed without the current password check. $token = Crypt::randomBytesBase64(55); @@ -76,7 +112,8 @@ public function submitForm(array &$form, array &$form_state) { $form_state['redirect_route']['options'] = array( 'query' => array('pass-reset-token' => $token), 'absolute' => TRUE, - ); + ); } } +