Keep setting the cookie so the expiration / max-age keeps renewing

Until now the session would expire 1 hour after the first action even
when you keep using the gui in between
This commit is contained in:
Arjan H
2022-08-06 16:42:28 +02:00
parent 09d2fcaf72
commit 3fed65af17

View File

@@ -2511,6 +2511,10 @@ func authorized(next http.Handler) http.Handler {
} else {
session, _ := sessionStore.Get(r, "labca")
if session.Values["user"] != nil || (r.RequestURI == "/setup" && viper.Get("user.password") == nil) {
// Keep setting the cookie so the expiration / max-age keeps renewing
if err := session.Save(r, w); err != nil {
log.Printf("cannot save session: %s\n", err)
}
next.ServeHTTP(w, r)
} else {
session.Values["bounce"] = r.RequestURI