This commit is contained in:
Jason Streifling 2025-01-14 21:27:24 +01:00
parent d953b4135c
commit 13a6039490
3 changed files with 4 additions and 5 deletions

View File

@ -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
}

View File

@ -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...)

View File

@ -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)