Skip to content

Commit

Permalink
feature #1464 [make:registration-form] use validateEmailConfirmationF…
Browse files Browse the repository at this point in the history
…romRequest() when verifying emails

* [make:registration-form] use the new validateEmailConfirmationRequest method

* use constructor property promotion
  • Loading branch information
jrushlow authored Mar 18, 2024
1 parent 33cb766 commit f4f5eb1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/Maker/MakeRegistrationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
use Symfony\Component\Validator\Validation;
use Symfony\Contracts\Translation\TranslatorInterface;
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
use SymfonyCasts\Bundle\VerifyEmail\Model\VerifyEmailSignatureComponents;
use SymfonyCasts\Bundle\VerifyEmail\SymfonyCastsVerifyEmailBundle;
use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelper;
use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelperInterface;

/**
Expand Down Expand Up @@ -444,13 +444,13 @@ private function getMissingComponentsComposerMessage(): ?string
$missing = false;
$composerMessage = 'composer require';

// verify-email-bundle 1.1.1 includes support for translations and a fix for the bad expiration time bug.
// we need to check that if the bundle is installed, it is version 1.1.1 or greater
// verify-email-bundle 1.17.0 includes the new validateEmailConfirmationFromRequest method.
// we need to check that if the bundle is installed, it is version 1.17.0 or greater
if (class_exists(SymfonyCastsVerifyEmailBundle::class)) {
$reflectedComponents = new \ReflectionClass(VerifyEmailSignatureComponents::class);
$reflectedComponents = new \ReflectionClass(VerifyEmailHelper::class);

if (!$reflectedComponents->hasMethod('getExpirationMessageKey')) {
throw new RuntimeCommandException('Please upgrade symfonycasts/verify-email-bundle to version 1.1.1 or greater.');
if (!$reflectedComponents->hasMethod('validateEmailConfirmationFromRequest')) {
throw new RuntimeCommandException('Please upgrade symfonycasts/verify-email-bundle to version 1.17.0 or greater.');
}
} else {
$missing = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
class <?= $class_name; ?> extends AbstractController
{
<?php if ($will_verify_email): ?>
private <?= $generator->getPropertyType($email_verifier_class_details) ?>$emailVerifier;

public function __construct(<?= $email_verifier_class_details->getShortName() ?> $emailVerifier)
public function __construct(private <?= $generator->getPropertyType($email_verifier_class_details) ?>$emailVerifier)
{
$this->emailVerifier = $emailVerifier;
}

<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/skeleton/verifyEmail/EmailVerifier.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function sendEmailConfirmation(string $verifyEmailRouteName, UserInterfac
*/
public function handleEmailConfirmation(Request $request, UserInterface $user): void
{
$this->verifyEmailHelper->validateEmailConfirmation($request->getUri(), $user-><?= $id_getter ?>(), $user-><?= $email_getter?>());
$this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, $user-><?= $id_getter ?>(), $user-><?= $email_getter?>());

$user->setIsVerified(true);

Expand Down

0 comments on commit f4f5eb1

Please sign in to comment.