Age Gate: Allow single-page exceptions with ?over18=1
This commit is contained in:
parent
0943ff34b1
commit
87f53c9895
|
@ -4,9 +4,9 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/kirsle/blog/models/settings"
|
||||||
"github.com/kirsle/blog/src/responses"
|
"github.com/kirsle/blog/src/responses"
|
||||||
"github.com/kirsle/blog/src/sessions"
|
"github.com/kirsle/blog/src/sessions"
|
||||||
"github.com/kirsle/blog/models/settings"
|
|
||||||
"github.com/urfave/negroni"
|
"github.com/urfave/negroni"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -48,8 +48,11 @@ func AgeGate(verifyHandler func(http.ResponseWriter, *http.Request)) negroni.Han
|
||||||
session := sessions.Get(r)
|
session := sessions.Get(r)
|
||||||
if val, _ := session.Values["age-ok"].(bool); !val {
|
if val, _ := session.Values["age-ok"].(bool); !val {
|
||||||
// They haven't been verified.
|
// They haven't been verified.
|
||||||
responses.Redirect(w, "/age-verify?next="+r.URL.Path)
|
// Allow single-page loads with ?over18=1 in query parameter.
|
||||||
return
|
if r.FormValue("over18") == "" {
|
||||||
|
responses.Redirect(w, "/age-verify?next="+r.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next(w, r)
|
next(w, r)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user