forked from jason/cpolis
Correctly handle errors from getSession
This commit is contained in:
@@ -67,7 +67,12 @@ func HomePage(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
session, _ := s.Get(r, "cookie")
|
||||
session, err := getSession(w, r, c, s)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if auth, ok := session.Values["authenticated"].(bool); auth && ok {
|
||||
files[1] = c.WebDir + "/templates/hub.html"
|
||||
tmpl, err := template.ParseFiles(files...)
|
||||
@@ -132,6 +137,8 @@ func Logout(c *b.Config, s *b.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
session, err := getSession(w, r, c, s)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -155,6 +162,8 @@ func ShowHub(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
session, err := getSession(w, r, c, s)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user