Loading reader.module +9 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,15 @@ function reader_form_user_login_form_alter(&$form, FormStateInterface $form_stat \Drupal::service('reader.form_alter')->alterLoginForm($form, $form_state); } /** * Implements hook_form_FORM_ID_alter(). */ function reader_form_user_pass_reset_alter(&$form, FormStateInterface $form_state) { if (isset($_SESSION['use_reader_theme'])) { \Drupal::service('reader.form_alter')->alterResetPasswordForm($form); } } /** * Prepares variables for list of available node type links and other content. * Loading reader.routing.yml +11 −0 Original line number Diff line number Diff line Loading @@ -145,3 +145,14 @@ reader.login: options: _maintenance_access: TRUE _reader_theme: 'reader_theme' reader.password: path: '/reader/user/password' defaults: _form: '\Drupal\reader\Form\ReaderUserPasswordForm' _title: 'Reset your password' requirements: _access: 'TRUE' options: _maintenance_access: TRUE _reader_theme: 'reader_theme' src/Form/ReaderUserPasswordForm.php 0 → 100644 +22 −0 Original line number Diff line number Diff line <?php namespace Drupal\reader\Form; use Drupal\Core\Form\FormStateInterface; use Drupal\user\Form\UserPasswordForm; /** * Provides the user password form. */ class ReaderUserPasswordForm extends UserPasswordForm { /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $_SESSION['use_reader_theme'] = TRUE; parent::submitForm($form, $form_state); $form_state->setRedirect('reader.login'); } } src/Services/ReaderFormAlter.php +22 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Link; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Url; Loading Loading @@ -113,6 +114,7 @@ class ReaderFormAlter implements ReaderFormAlterInterface { return; } $form['reset_link'] = ['#markup' => '<p class="user-link">' . Link::createFromRoute($this->t('Forgot password?'), 'reader.password')->toString() . '</p>']; $form['#submit'][] = [$this, 'loginSubmit']; } Loading @@ -139,6 +141,26 @@ class ReaderFormAlter implements ReaderFormAlterInterface { } } /** * {@inheritdoc} */ public function alterResetPasswordForm(array &$form) { unset($_SESSION['use_reader_theme']); $form['#action'] .= '?destination=/reader'; } /** * Submit callback after reset login. * * @param array $form * @param \Drupal\Core\Form\FormStateInterface $form_state * * @see alterLoginForm(); */ public function resetSubmit(array &$form, FormStateInterface $form_state) { $form_state->setRedirect('reader.home'); } /** * Returns whether this is a reader content route or not. * Loading src/Services/ReaderFormAlterInterface.php +7 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,11 @@ interface ReaderFormAlterInterface { */ public function alterLoginForm(array &$form, FormStateInterface $form_state); /** * Alter the user reset password form. * * @param array $form */ public function alterResetPasswordForm(array &$form); } Loading
reader.module +9 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,15 @@ function reader_form_user_login_form_alter(&$form, FormStateInterface $form_stat \Drupal::service('reader.form_alter')->alterLoginForm($form, $form_state); } /** * Implements hook_form_FORM_ID_alter(). */ function reader_form_user_pass_reset_alter(&$form, FormStateInterface $form_state) { if (isset($_SESSION['use_reader_theme'])) { \Drupal::service('reader.form_alter')->alterResetPasswordForm($form); } } /** * Prepares variables for list of available node type links and other content. * Loading
reader.routing.yml +11 −0 Original line number Diff line number Diff line Loading @@ -145,3 +145,14 @@ reader.login: options: _maintenance_access: TRUE _reader_theme: 'reader_theme' reader.password: path: '/reader/user/password' defaults: _form: '\Drupal\reader\Form\ReaderUserPasswordForm' _title: 'Reset your password' requirements: _access: 'TRUE' options: _maintenance_access: TRUE _reader_theme: 'reader_theme'
src/Form/ReaderUserPasswordForm.php 0 → 100644 +22 −0 Original line number Diff line number Diff line <?php namespace Drupal\reader\Form; use Drupal\Core\Form\FormStateInterface; use Drupal\user\Form\UserPasswordForm; /** * Provides the user password form. */ class ReaderUserPasswordForm extends UserPasswordForm { /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $_SESSION['use_reader_theme'] = TRUE; parent::submitForm($form, $form_state); $form_state->setRedirect('reader.login'); } }
src/Services/ReaderFormAlter.php +22 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Link; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Url; Loading Loading @@ -113,6 +114,7 @@ class ReaderFormAlter implements ReaderFormAlterInterface { return; } $form['reset_link'] = ['#markup' => '<p class="user-link">' . Link::createFromRoute($this->t('Forgot password?'), 'reader.password')->toString() . '</p>']; $form['#submit'][] = [$this, 'loginSubmit']; } Loading @@ -139,6 +141,26 @@ class ReaderFormAlter implements ReaderFormAlterInterface { } } /** * {@inheritdoc} */ public function alterResetPasswordForm(array &$form) { unset($_SESSION['use_reader_theme']); $form['#action'] .= '?destination=/reader'; } /** * Submit callback after reset login. * * @param array $form * @param \Drupal\Core\Form\FormStateInterface $form_state * * @see alterLoginForm(); */ public function resetSubmit(array &$form, FormStateInterface $form_state) { $form_state->setRedirect('reader.home'); } /** * Returns whether this is a reader content route or not. * Loading
src/Services/ReaderFormAlterInterface.php +7 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,11 @@ interface ReaderFormAlterInterface { */ public function alterLoginForm(array &$form, FormStateInterface $form_state); /** * Alter the user reset password form. * * @param array $form */ public function alterResetPasswordForm(array &$form); }