From 81f093c2d02884cb2378111680c4e48c48ad7b8b Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Wed, 8 Apr 2026 20:20:19 +0200 Subject: [PATCH] feat: bouton renvoyer le code sur page verification echeancier - Route /echeancier/verify/{id}/resend (POST) - Genere nouveau code 6 chiffres + envoie par email - Bouton "Renvoyer le code" sous le formulaire Co-Authored-By: Claude Opus 4.6 (1M context) --- .../EcheancierProcessController.php | 36 +++++++++++++++++++ templates/echeancier/verify.html.twig | 4 +++ 2 files changed, 40 insertions(+) diff --git a/src/Controller/EcheancierProcessController.php b/src/Controller/EcheancierProcessController.php index a812049..a7d8cf6 100644 --- a/src/Controller/EcheancierProcessController.php +++ b/src/Controller/EcheancierProcessController.php @@ -98,6 +98,42 @@ class EcheancierProcessController extends AbstractController ]); } + /** + * Renvoie le code de verification. + */ + #[Route('/echeancier/verify/{id}/resend', name: 'app_echeancier_resend_code', requirements: ['id' => '\d+'], methods: ['POST'])] + public function resendCode(int $id, Request $request): Response + { + $echeancier = $this->em->getRepository(Echeancier::class)->find($id); + if (null === $echeancier) { + throw $this->createNotFoundException('Echeancier introuvable.'); + } + + $customer = $echeancier->getCustomer(); + $session = $request->getSession(); + + if (null !== $customer->getEmail()) { + $code = str_pad((string) random_int(0, 999999), 6, '0', \STR_PAD_LEFT); + $session->set('echeancier_code_'.$id, $code); + $session->set('echeancier_code_expires_'.$id, time() + 900); + + $this->mailer->sendEmail( + $customer->getEmail(), + 'Nouveau code de verification - Echeancier', + $this->twig->render('emails/order_verify_code.html.twig', [ + 'customer' => $customer, + 'advert' => null, + 'code' => $code, + ]), + null, + null, + false, + ); + } + + return $this->redirectToRoute('app_echeancier_verify', ['id' => $id]); + } + /** * Page de detail echeancier avant signature (protegee par code). */ diff --git a/templates/echeancier/verify.html.twig b/templates/echeancier/verify.html.twig index fcdbcd6..eaae832 100644 --- a/templates/echeancier/verify.html.twig +++ b/templates/echeancier/verify.html.twig @@ -28,6 +28,10 @@

Le code expire dans 15 minutes.

+ +
+ +