From ab5c370a3947c619815c5f1a36f1d4ee0dd2546f Mon Sep 17 00:00:00 2001
From: pfleu <fleutotp@gmail.com>
Date: Tue, 3 Oct 2023 22:11:32 +0200
Subject: [PATCH] =?UTF-8?q?Modif=20email=20r=C3=A9initialisation=20mot=20d?=
 =?UTF-8?q?e=20passe=20qui=20n'=C3=A9tait=20pas=20envoy=C3=A9=20en=20prod?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/Controller/ResetPasswordController.php | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php
index d161769..b9924c1 100644
--- a/src/Controller/ResetPasswordController.php
+++ b/src/Controller/ResetPasswordController.php
@@ -13,8 +13,10 @@ use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Mailer\MailerInterface;
 use Symfony\Component\Mime\Address;
+use Symfony\Component\Mime\Email;
 use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
 use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Contracts\Translation\TranslatorInterface;
 use SymfonyCasts\Bundle\ResetPassword\Controller\ResetPasswordControllerTrait;
 use SymfonyCasts\Bundle\ResetPassword\Exception\ResetPasswordExceptionInterface;
@@ -164,15 +166,15 @@ class ResetPasswordController extends AbstractController
             return $this->redirectToRoute('app_check_email');
         }
 
-        $email = (new TemplatedEmail())
-            ->from(new Address('no-reply@balex.fr', 'Base Balex'))
+        $url = $this->generateUrl('app_reset_password', ['token' => $resetToken->getToken()], UrlGeneratorInterface::ABSOLUTE_URL);
+        $link = sprintf('<a href="%s">%s</a>', $url, $url);
+
+        $email = (new Email())
+            ->from($_ENV['MAILER_FROM'])
             ->to($user->getEmail())
             ->subject('Réinitialisation de votre mot de passe')
-            ->htmlTemplate('reset_password/email.html.twig')
-            ->context([
-                'resetToken' => $resetToken,
-            ])
-        ;
+            ->html('<h1>Bonjour</h1>
+                        <p>Pour réinitialiser votre mot de passe, veuillez cliquer sur le lien suivant:</p>' . $link);
 
         $mailer->send($email);
 
-- 
GitLab