Check if we are logged in
This commit is contained in:
parent
f70d1ccc05
commit
8e2dd0993a
17
main.go
17
main.go
|
@ -190,6 +190,11 @@ func (h *historyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
defer sess.Flush()
|
||||
|
||||
if !sess.LoggedIn {
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
r.ParseForm()
|
||||
page := r.URL.Path[9:]
|
||||
if page == "" {
|
||||
|
@ -203,7 +208,7 @@ func (h *historyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
funcs := template.FuncMap{
|
||||
"historyIndex": func(x int, history []Revision) int { return len(history) - x; },
|
||||
"historyIndex": func(x int, history []Revision) int { return len(history) - x },
|
||||
}
|
||||
|
||||
t, err := template.New("layout.html").Funcs(funcs).ParseFiles("templates/layout.html", "templates/history.html")
|
||||
|
@ -234,6 +239,11 @@ func (h *saveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
defer sess.Flush()
|
||||
|
||||
if !sess.LoggedIn {
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
r.ParseForm()
|
||||
page := r.PostForm.Get("p")
|
||||
summary := r.PostForm.Get("summary")
|
||||
|
@ -252,6 +262,11 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
defer sess.Flush()
|
||||
|
||||
if !sess.LoggedIn {
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
page := r.URL.Path[6:]
|
||||
if page == "" {
|
||||
page = "Home"
|
||||
|
|
Loading…
Reference in New Issue
Block a user