mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-17 05:53:15 +02:00
Return better information on JSON parsing errors, that no action is recorded in that case
This commit is contained in:
@@ -292,7 +292,7 @@ func BanNotificationHandler(c *gin.Context) {
|
|||||||
log.Printf("❌ Validation error: Field '%s' violated rule '%s'", fe.Field(), fe.ActualTag())
|
log.Printf("❌ Validation error: Field '%s' violated rule '%s'", fe.Field(), fe.ActualTag())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("❌ JSON parsing error: %v", err)
|
log.Printf("❌ JSON parsing error -> Action will not be recorded! Details: %v", err)
|
||||||
}
|
}
|
||||||
log.Printf("Raw JSON: %s", string(body))
|
log.Printf("Raw JSON: %s", string(body))
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request: " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request: " + err.Error()})
|
||||||
@@ -361,7 +361,7 @@ func UnbanNotificationHandler(c *gin.Context) {
|
|||||||
log.Printf("❌ Validation error: Field '%s' violated rule '%s'", fe.Field(), fe.ActualTag())
|
log.Printf("❌ Validation error: Field '%s' violated rule '%s'", fe.Field(), fe.ActualTag())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("❌ JSON parsing error: %v", err)
|
log.Printf("❌ JSON parsing error -> Action will not be recorded! Details: %v", err)
|
||||||
}
|
}
|
||||||
log.Printf("Raw JSON: %s", string(body))
|
log.Printf("Raw JSON: %s", string(body))
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request: " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request: " + err.Error()})
|
||||||
@@ -2448,7 +2448,6 @@ func getEmailStyle() string {
|
|||||||
return "modern"
|
return "modern"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Connects to the SMTP server and delivers a single HTML message.
|
// Connects to the SMTP server and delivers a single HTML message.
|
||||||
func sendEmail(to, subject, body string, settings config.AppSettings) error {
|
func sendEmail(to, subject, body string, settings config.AppSettings) error {
|
||||||
// Skips sending if the destination email is still the default placeholder
|
// Skips sending if the destination email is still the default placeholder
|
||||||
|
|||||||
Reference in New Issue
Block a user