From 0f849468f70b6d9cf0c51d154dbb25dfd7d133e3 Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Thu, 30 Apr 2026 13:52:09 +0200 Subject: [PATCH] feat: inline email retry on 550 rejection in tfe access request form --- TODO.md | 1 + app/public/assets/css/tfe.css | 5 +++++ app/storage/logs/form-submissions.log | 1 + app/templates/public/tfe.php | 25 +++++++++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/TODO.md b/TODO.md index 076d76f..8648771 100644 --- a/TODO.md +++ b/TODO.md @@ -20,6 +20,7 @@ ## Bug fixes - [x] **smtp-test.php** — wrap `SmtpRelay::send()` in `try/catch SmtpSendException` so SMTP delivery failures (e.g. 550 recipient rejected) surface as a proper flash error instead of an uncaught exception/silent crash - [x] **partage email retry** — on 550 recipient-rejected, redirect to `/partage/retry-email` instead of `recapitulatif`; student can correct address and resend or skip +- [x] **tfe access form email retry** — on `recipient_rejected` JSON response, highlight email field in red, show corrected error message, let user fix and resubmit inline - [x] **ThesisCreateController** — `confirmation_email` is now optional (empty = skip send) - [x] **admin/add.php template** — email confirmation field marked optional, label and hint updated diff --git a/app/public/assets/css/tfe.css b/app/public/assets/css/tfe.css index 12e2736..e0b1e52 100644 --- a/app/public/assets/css/tfe.css +++ b/app/public/assets/css/tfe.css @@ -324,6 +324,11 @@ aside figcaption { color: #742a2a; } +.tfe-access-request-form input.input-error { + border-color: #fc8181; + outline-color: #fc8181; +} + /* Responsive */ @media (max-width: 900px) { .tfe-layout { diff --git a/app/storage/logs/form-submissions.log b/app/storage/logs/form-submissions.log index a3fe82e..6ee3574 100644 --- a/app/storage/logs/form-submissions.log +++ b/app/storage/logs/form-submissions.log @@ -7,3 +7,4 @@ {"source":"partage","action":"submit","status":"success","thesis_id":21,"identifier":"2025-018","author":"Théo Marchand","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T11:41:38+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"} {"source":"partage","action":"submit","status":"success","thesis_id":22,"identifier":"2025-019","author":"Lila Dubois, Karim Nassar","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T11:45:36+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"} {"source":"partage","action":"submit","status":"success","thesis_id":23,"identifier":"2025-020","author":"Zoé Lambert","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T11:46:49+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"} +{"source":"partage","action":"submit","status":"success","thesis_id":24,"identifier":"2025-021","author":"Emma Renard","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T11:49:49+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"} diff --git a/app/templates/public/tfe.php b/app/templates/public/tfe.php index 08b262c..185a479 100644 --- a/app/templates/public/tfe.php +++ b/app/templates/public/tfe.php @@ -327,6 +327,25 @@ justificationInput.required = !isErg; }); + function showRetryPrompt(rejectedEmail, serverMessage) { + messageDiv.style.display = 'block'; + messageDiv.className = 'tfe-access-message tfe-access-error'; + messageDiv.innerHTML = + 'Adresse e-mail introuvable sur le serveur de l\'ERG.
' + + '' + serverMessage.replace(/

' + + 'Corrigez votre adresse e-mail et réessayez.'; + // Highlight the email field and let the user fix it + emailInput.value = rejectedEmail; + emailInput.classList.add('input-error'); + emailInput.focus(); + emailInput.select(); + // Remove error highlight once they start typing + emailInput.addEventListener('input', function clearError() { + emailInput.classList.remove('input-error'); + emailInput.removeEventListener('input', clearError); + }); + } + // Form submission form.addEventListener('submit', function(e) { e.preventDefault(); @@ -336,6 +355,7 @@ submitBtn.textContent = 'Envoi en cours...'; messageDiv.style.display = 'none'; + const submittedEmail = emailInput.value.trim(); const formData = new FormData(form); formData.append('thesis_id', ''); @@ -348,6 +368,11 @@ submitBtn.disabled = false; submitBtn.textContent = 'Demander l\'accès'; + if (data.status === 'recipient_rejected') { + showRetryPrompt(submittedEmail, data.message); + return; + } + messageDiv.style.display = 'block'; if (data.success) { messageDiv.className = 'tfe-access-message tfe-access-success';