+ Status: {% if user.isVerified %}✓ Verified{% else %}⏳ Awaiting Email Verification{% endif %}
+ Email Verified: {% if user.isVerified %}Yes{% else %}No - activation link sent{% endif %} +
diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index b5c8e20..c66bf0b 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -19,6 +19,7 @@ use DateTime; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bridge\Twig\Mime\TemplatedEmail; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Attribute\AsController; @@ -41,6 +42,12 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; #[AsController] class SecurityController extends AbstractController { + public function __construct( + #[Autowire(env: 'APP_CONTACT_MAIL_ADDRESS')] + private readonly string $appContactMailAddress, + ) { + } + #[Route('/login', name: 'MineSeekerBundle_login')] public function login(AuthenticationUtils $authenticationUtils): Response { @@ -92,7 +99,7 @@ class SecurityController extends AbstractController UrlGeneratorInterface::ABSOLUTE_URL, ); - // Ensure HTTPS scheme in production + /** Ensure HTTPS scheme in production */ if ($this->getParameter('kernel.environment') === 'prod') { $activationUrl = str_replace('http://', 'https://', $activationUrl); } @@ -109,6 +116,19 @@ class SecurityController extends AbstractController ]) ); + /** Send admin notification about new user registration */ + $mailer->send( + new TemplatedEmail() + ->from('noreply@mineseeker.hu') + ->to($this->appContactMailAddress) + ->subject('🎉 New User Registration: ' . $user->getUsername()) + ->htmlTemplate('emails/user_registration_notification.html.twig') + ->context([ + 'user' => $user, + 'registeredAt' => new DateTime(), + ]) + ); + $this->addFlash('verify_email', $user->getEmail()); return $this->redirectToRoute('MineSeekerBundle_register'); @@ -148,7 +168,7 @@ class SecurityController extends AbstractController UrlGeneratorInterface::ABSOLUTE_URL, ); - // Ensure HTTPS scheme in production + /** Ensure HTTPS scheme in production */ if ($this->getParameter('kernel.environment') === 'prod') { $resetUrl = str_replace('http://', 'https://', $resetUrl); } diff --git a/templates/emails/user_registration_notification.html.twig b/templates/emails/user_registration_notification.html.twig new file mode 100644 index 0000000..7a166dd --- /dev/null +++ b/templates/emails/user_registration_notification.html.twig @@ -0,0 +1,93 @@ + + +
+ +