From 13a60394906430002ba67bb85c18f121a42be82e Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 14 Jan 2025 21:27:24 +0100 Subject: [PATCH] Bug fix --- cmd/frontend/articles.go | 1 - cmd/frontend/homepage.go | 2 +- cmd/frontend/sessions.go | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/frontend/articles.go b/cmd/frontend/articles.go index b32e835..9a7292d 100644 --- a/cmd/frontend/articles.go +++ b/cmd/frontend/articles.go @@ -57,7 +57,6 @@ func WriteArticle(c *b.Config, db *b.DB, s map[string]*Session) http.HandlerFunc if session.Article == nil { data.Article = new(b.Article) } else { - // data = session.Values["article"].(*EditorHTMLData) data.Article = session.Article } diff --git a/cmd/frontend/homepage.go b/cmd/frontend/homepage.go index d74c1ff..9245b8d 100644 --- a/cmd/frontend/homepage.go +++ b/cmd/frontend/homepage.go @@ -39,7 +39,7 @@ func HomePage(c *b.Config, db *b.DB, s map[string]*Session) http.HandlerFunc { return } } else { - cookie, err := r.Cookie("session_id") + cookie, err := r.Cookie("cpolis_session") if err != nil { files[1] = c.WebDir + "/templates/login.html" tmpl, err := template.ParseFiles(files...) diff --git a/cmd/frontend/sessions.go b/cmd/frontend/sessions.go index f1ab633..105b5d3 100644 --- a/cmd/frontend/sessions.go +++ b/cmd/frontend/sessions.go @@ -70,7 +70,7 @@ func StartSessions() (map[string]*Session, chan string) { func ManageSession(w http.ResponseWriter, r *http.Request, c *b.Config, s map[string]*Session) (*Session, error) { tmpl, tmplErr := template.ParseFiles(c.WebDir+"/templates/index.html", c.WebDir+"/templates/login.html") - cookie, err := r.Cookie("session_id") + cookie, err := r.Cookie("cpolis_session") if err != nil { if err = template.Must(tmpl, tmplErr).ExecuteTemplate(w, "page-content", nil); err != nil { return nil, fmt.Errorf("error executing template: %v", err) @@ -92,7 +92,7 @@ func ManageSession(w http.ResponseWriter, r *http.Request, c *b.Config, s map[st } session.cookie.Expires = time.Now().Add(time.Hour * time.Duration(c.CookieExpiryHours)) - http.SetCookie(w, cookie) + http.SetCookie(w, session.cookie) return session, nil } @@ -138,7 +138,7 @@ func Logout(c *b.Config, s map[string]*Session) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { tmpl, tmplErr := template.ParseFiles(c.WebDir + "/templates/login.html") - cookie, err := r.Cookie("session_id") + cookie, err := r.Cookie("cpolis_session") if err != nil { if err = template.Must(tmpl, tmplErr).ExecuteTemplate(w, "page-content", nil); err != nil { log.Println(err)