From 8afcbbe2be77a5d8ff9437e750daf48d63358b1c Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 18 Jun 2023 11:58:04 +0000 Subject: [PATCH] Fix age gate page to defend against common user error --- pkg/controller/account/age_gate.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/controller/account/age_gate.go b/pkg/controller/account/age_gate.go index 2a78851..a75a371 100644 --- a/pkg/controller/account/age_gate.go +++ b/pkg/controller/account/age_gate.go @@ -49,7 +49,12 @@ func AgeGate() http.HandlerFunc { } // 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. fb := &models.Feedback{ Intent: "report",