From 6e191bdf06bd800ae76dfaf32055d358f6d81c04 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 +- src/User/Controller/RecoveryController.php | 8 ++++++-- src/User/Module.php | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 880f9ee3..576292c1 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/src/User/Controller/RecoveryController.php b/src/User/Controller/RecoveryController.php index 9e675c19..9602f95c 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 5cd8d639..a6c68cde 100755 --- a/src/User/Module.php +++ b/src/User/Module.php @@ -220,6 +220,7 @@ class Module extends BaseModule '' => 'registration/', 'confirm//' => 'registration/confirm', 'forgot' => 'recovery/request', + 'forgot/' => 'recovery/request', 'recover//' => 'recovery/reset' ]; /**