From 27827bd2a9c8487099b47a746276f6c20a51a83a Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 16 Jan 2026 21:01:01 +0100 Subject: [PATCH] Added domain to verification mail --- src/Tech/Service/EmailVerifier.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Tech/Service/EmailVerifier.php b/src/Tech/Service/EmailVerifier.php index 6dbcddc..c50e67b 100644 --- a/src/Tech/Service/EmailVerifier.php +++ b/src/Tech/Service/EmailVerifier.php @@ -7,6 +7,7 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Bridge\Twig\Mime\TemplatedEmail; use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface; use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelperInterface; @@ -15,12 +16,34 @@ class EmailVerifier public function __construct( private VerifyEmailHelperInterface $verifyEmailHelper, private MailerInterface $mailer, - private EntityManagerInterface $entityManager + private EntityManagerInterface $entityManager, + private UrlGeneratorInterface $router ) { } public function sendEmailConfirmation(string $verifyEmailRouteName, User $user, TemplatedEmail $email): void { + $context = $this->router->getContext(); + if (empty($context->getHost())) { + $siteBaseUrl = $_ENV['SITE_BASE_URL'] ?? null; + if ($siteBaseUrl) { + $parts = parse_url($siteBaseUrl); + if (isset($parts['host'])) { + $context->setHost($parts['host']); + } + if (isset($parts['scheme'])) { + $context->setScheme($parts['scheme']); + } + if (isset($parts['port'])) { + if ('http' === $parts['scheme']) { + $context->setHttpPort($parts['port']); + } elseif ('https' === $parts['scheme']) { + $context->setHttpsPort($parts['port']); + } + } + } + } + $signatureComponents = $this->verifyEmailHelper->generateSignature( $verifyEmailRouteName, (string) $user->getId(),