This commit is contained in:
lbenedar
2026-03-06 14:44:08 +03:00
parent 894d152aae
commit 94345eff97
6 changed files with 42 additions and 17 deletions

View File

@@ -38,3 +38,14 @@ func (app *application) recoverPanic(next http.Handler) http.Handler {
next.ServeHTTP(w, r)
})
}
func (app *application) requireAuthentication(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !app.isAuthenticated(r) {
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
return
}
w.Header().Set("Cache-Control", "no-store")
next.ServeHTTP(w, r)
})
}