$this->t('

This is a one-time login for %user_name and will expire on %expiration_date.

Click on this button to log in to the site and change your password.

', ['%user_name' => $user->getUsername(), '%expiration_date' => $expiration_date])]; $form['#title'] = $this->t('Reset password'); } else { // No expiration for first time login. $form['message'] = ['#markup' => $this->t('

This is a one-time login for %user_name.

Click on this button to log in to the site and change your password.

', ['%user_name' => $user->getUsername()])]; $form['#title'] = $this->t('Set password'); } $form['help'] = ['#markup' => '

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

']; $form['actions'] = ['#type' => 'actions']; $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Log in'), ]; $form['#action'] = Url::fromRoute('user.reset.login', [ 'uid' => $user->id(), 'timestamp' => $timestamp, 'hash' => $hash, ])->toString(); return $form; } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // This form works by submitting the hash and timestamp to the user.reset // route with a 'login' action. } }