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,9 +48,12 @@ 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.
|
||||||
|
// Allow single-page loads with ?over18=1 in query parameter.
|
||||||
|
if r.FormValue("over18") == "" {
|
||||||
responses.Redirect(w, "/age-verify?next="+r.URL.Path)
|
responses.Redirect(w, "/age-verify?next="+r.URL.Path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
next(w, r)
|
next(w, r)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user