fix(platform): sanitize Spring mail test failures

This commit is contained in:
sechmachine
2026-08-15 03:24:59 +07:00
parent 62a21132e2
commit bf6f9af78b
3 changed files with 83 additions and 5 deletions
@@ -9,6 +9,7 @@ import com.lab.labtimesheet.feature.integration.model.dto.SmtpForm;
import com.lab.labtimesheet.feature.integration.service.SmtpConfigurationService;
import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid;
import org.springframework.mail.MailException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
@@ -76,7 +77,7 @@ class SmtpController {
try {
smtp.testDraft(action.getDraftId(), adminId(principal), principal.getName());
return "redirect:/admin/smtp?tested";
} catch (IllegalArgumentException | IllegalStateException failure) {
} catch (IllegalArgumentException | IllegalStateException | MailException failure) {
bindingResult.reject("smtp.test.failed", TEST_FAILURE_MESSAGE);
return renderActionError(model, bindingResult);
}