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) <noreply@anthropic.com>
This commit is contained in:
@@ -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).
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
</form>
|
||||
|
||||
<p class="text-center text-xs text-gray-400 mt-4">Le code expire dans 15 minutes.</p>
|
||||
|
||||
<form method="post" action="{{ path('app_echeancier_resend_code', {id: echeancier.id}) }}" class="mt-3 text-center">
|
||||
<button type="submit" class="text-xs font-bold uppercase tracking-wider text-gray-500 hover:text-gray-900 underline transition-all">Renvoyer le code</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user