Tweaks to age-gate middleware

Allow more static files to be loaded: font files like for FontAwesome.
Also allow POST requests, in case you loaded a URL with the override
query parameter so you can leave a comment without being interrupted.
This commit is contained in:
Noah 2019-10-22 10:50:51 -07:00
parent 445fffdf2b
commit d78814b9c9

View File

@ -24,6 +24,11 @@ var ageGateSuffixes = []string{
".gif",
".mp4",
".webm",
".ttf",
".eot",
".svg",
".woff",
".woff2",
}
// AgeGate is a middleware generator that does age verification for NSFW sites.
@ -49,6 +54,12 @@ func AgeGate(verifyHandler func(http.ResponseWriter, *http.Request)) negroni.Han
}
}
// POST requests are allowed.
if r.Method == http.MethodPost {
next(w, r)
return
}
// See if they've been cleared.
session := sessions.Get(r)
if val, _ := session.Values["age-ok"].(bool); !val {