ch17
This commit is contained in:
@@ -24,9 +24,9 @@ func secureHeaders(next http.Handler) http.Handler {
|
||||
func noSurf(next http.Handler) http.Handler {
|
||||
csrfHanlder := nosurf.New(next)
|
||||
csrfHanlder.SetBaseCookie(http.Cookie{
|
||||
HttpOnly: true,
|
||||
HttpOnly: false,
|
||||
Path: "/",
|
||||
Secure: true,
|
||||
Secure: false,
|
||||
})
|
||||
|
||||
return csrfHanlder
|
||||
@@ -56,6 +56,7 @@ func (app *application) recoverPanic(next http.Handler) http.Handler {
|
||||
func (app *application) requireAuthentication(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if !app.isAuthenticated(r) {
|
||||
app.sessionManager.Put(r.Context(), "redirectParent", r.URL.Path)
|
||||
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user