Fix age gate page to defend against common user error

This commit is contained in:
Noah Petherbridge 2023-06-18 11:58:04 +00:00
parent 16da91ce1e
commit 8afcbbe2be

View File

@ -49,7 +49,12 @@ func AgeGate() http.HandlerFunc {
} }
// Validate birthdate is at least age 18. // Validate birthdate is at least age 18.
if utility.Age(birthdate) < 18 { if utility.Age(birthdate) <= 5 {
// Probably an error: seen some users enter current year by mistake, don't instantly ban them.
session.FlashError(w, r, "Please enter a valid birthdate. The year you entered (%d) was probably incorrect.", birthdate.Year())
templates.Redirect(w, r.URL.Path)
return
} else if utility.Age(birthdate) < 18 {
// Lock their account and notify the admins. // Lock their account and notify the admins.
fb := &models.Feedback{ fb := &models.Feedback{
Intent: "report", Intent: "report",