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:
parent
445fffdf2b
commit
d78814b9c9
|
@ -24,6 +24,11 @@ var ageGateSuffixes = []string{
|
||||||
".gif",
|
".gif",
|
||||||
".mp4",
|
".mp4",
|
||||||
".webm",
|
".webm",
|
||||||
|
".ttf",
|
||||||
|
".eot",
|
||||||
|
".svg",
|
||||||
|
".woff",
|
||||||
|
".woff2",
|
||||||
}
|
}
|
||||||
|
|
||||||
// AgeGate is a middleware generator that does age verification for NSFW sites.
|
// 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.
|
// See if they've been cleared.
|
||||||
session := sessions.Get(r)
|
session := sessions.Get(r)
|
||||||
if val, _ := session.Values["age-ok"].(bool); !val {
|
if val, _ := session.Values["age-ok"].(bool); !val {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user