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.
dependabot/go_modules/github.com/microcosm-cc/bluemonday-1.0.16
Noah 2019-10-22 10:50:51 -07:00
parent 445fffdf2b
commit d78814b9c9
1 changed files with 11 additions and 0 deletions

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 {