feat: inline email retry on 550 rejection in tfe access request form

This commit is contained in:
Pontoporeia
2026-04-30 13:52:09 +02:00
parent da53bf5d7a
commit 0f849468f7
4 changed files with 32 additions and 0 deletions

View File

@@ -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 =
'<strong>Adresse e-mail introuvable sur le serveur de l\'ERG.</strong><br>' +
'<small>' + serverMessage.replace(/</g, '&lt;') + '</small><br><br>' +
'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', '<?= $thesisId ?>');
@@ -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';