From 66aeeff584691bca9ed39c56e6ce4dae5d55fb40 Mon Sep 17 00:00:00 2001 From: tonis Date: Wed, 18 Sep 2024 17:19:57 +0300 Subject: [PATCH] Ehh: Added option to pre-fill recovery email via url parameter --- .github/workflows/php.yml | 2 +- CHANGELOG.md | 1 + src/User/Controller/RecoveryController.php | 8 ++++++-- src/User/Module.php | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index d4676482..d622ea90 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -76,7 +76,7 @@ jobs: run: vendor/bin/phpstan analyse - name: Archive failed tests artifacts - test output & log - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: test-outputs-php-${{ matrix.php-versions }} diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f23ab3..7372a8a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - New #553: created Da\User\AuthClient\Microsoft365 auth client (edegaudenzi) - Ehh: Added SecurityHelper to the Bootstrap classMap - Fix #397: No more fatal Exceptions when connecting to already taken Social Network (edegaudenzi) +- Ehh: Added option to pre-fill recovery email via url parameter (TonisOrmisson) ## 1.6.3 Mar 18th, 2024 diff --git a/src/User/Controller/RecoveryController.php b/src/User/Controller/RecoveryController.php index 9925c874..2367ef20 100644 --- a/src/User/Controller/RecoveryController.php +++ b/src/User/Controller/RecoveryController.php @@ -89,14 +89,18 @@ public function actionRequest() throw new NotFoundHttpException(); } + $request = Yii::$app->request; + /** @var RecoveryForm $form */ $form = $this->make(RecoveryForm::class, [], ['scenario' => RecoveryForm::SCENARIO_REQUEST]); - + if(!$request->getIsPost() && !empty($request->get('email'))) { + $form->email = $request->get('email'); + } $event = $this->make(FormEvent::class, [$form]); $this->make(AjaxRequestModelValidator::class, [$form])->validate(); - if ($form->load(Yii::$app->request->post()) && $form->validate()) { + if ($form->load($request->post()) && $form->validate()) { $this->trigger(FormEvent::EVENT_BEFORE_REQUEST, $event); $mailService = MailFactory::makeRecoveryMailerService($form->email); diff --git a/src/User/Module.php b/src/User/Module.php index a27360b6..8749715a 100755 --- a/src/User/Module.php +++ b/src/User/Module.php @@ -219,6 +219,7 @@ class Module extends BaseModule '' => 'registration/', 'confirm//' => 'registration/confirm', 'forgot' => 'recovery/request', + 'forgot/' => 'recovery/request', 'recover//' => 'recovery/reset' ]; /**