smtp: typed probe errors with per-field UI highlighting on save

This commit is contained in:
Pontoporeia
2026-04-30 12:16:52 +02:00
parent b750aca2f5
commit bdb68479d5
7 changed files with 341 additions and 198 deletions

View File

@@ -51,9 +51,12 @@ if ($section === 'formulaire') {
// Immediately probe the server to validate credentials
$test = SmtpRelay::test($db);
if ($test['ok']) {
App::flash('success', "Paramètres SMTP mis à jour — connexion validée avec succès ");
App::flash('success', "Paramètres SMTP mis à jour — connexion validée ✓");
} else {
App::flash('error', "Paramètres sauvegardés, mais le test de connexion SMTP a échoué : " . $test['error']);
App::flash('error', "Paramètres sauvegardés, mais le test de connexion a échoué : " . $test['error']);
if ($test['field'] !== null) {
$_SESSION['_flash_smtp_field'] = $test['field'];
}
}
} else {
App::flash('error', "Section inconnue.");

View File

@@ -13,8 +13,10 @@ require_once APP_ROOT . '/src/SmtpRelay.php';
$db = new Database();
$siteSettings = $db->getAllSettings();
$stats = $db->getThesesStats();
$smtpSettings = SmtpRelay::getSettings($db);
$smtpConfigured = SmtpRelay::isConfigured($db);
$smtpSettings = SmtpRelay::getSettings($db);
$smtpConfigured = SmtpRelay::isConfigured($db);
$smtpErrorField = $_SESSION['_flash_smtp_field'] ?? null;
unset($_SESSION['_flash_smtp_field']);
// ── System section ────────────────────────────────────────────────────────────
require_once APP_ROOT . '/src/SystemCache.php';

View File

@@ -1275,6 +1275,20 @@
padding: 0 var(--space-xs);
}
/* SMTP field validation error state */
.param-grid input[aria-invalid="true"],
.param-grid select[aria-invalid="true"] {
border-bottom-color: var(--search-error-border, #c0392b);
}
.param-field-error {
display: block;
font-size: var(--step--2);
color: var(--search-error-border, #c0392b);
margin-top: var(--space-3xs);
line-height: 1.3;
}
/* ── Settings page sections — legacy aliases (kept for any remaining use) ─ */
.admin-settings-section {
border: 1px solid var(--border-primary);