summaryrefslogtreecommitdiff
path: root/pkg/webui/sessions.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/webui/sessions.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/pkg/webui/sessions.go b/pkg/webui/sessions.go
index 6d492d5..2d99871 100644
--- a/pkg/webui/sessions.go
+++ b/pkg/webui/sessions.go
@@ -22,16 +22,7 @@ func sessionsMiddleware(db *database.DB) func(http.Handler) http.Handler {
}
if err == nil {
if len(cookie.Value) != 36 {
- http.SetCookie(w, &http.Cookie{
- Name: cookieName,
- Value: "",
- Quoted: false,
- Path: "/",
- MaxAge: 0, // remove invalid cookie
- HttpOnly: true,
- SameSite: http.SameSiteStrictMode,
- Secure: true,
- })
+ unsetSesssionCookie(w)
} else {
session, err := db.LoadSessionById(cookie.Value)
if err != nil {
@@ -53,3 +44,16 @@ func sessionsMiddleware(db *database.DB) func(http.Handler) http.Handler {
})
}
}
+
+func unsetSesssionCookie(w http.ResponseWriter) {
+ http.SetCookie(w, &http.Cookie{
+ Name: cookieName,
+ Value: "",
+ Quoted: false,
+ Path: "/",
+ MaxAge: 0, // remove invalid cookie
+ HttpOnly: true,
+ SameSite: http.SameSiteStrictMode,
+ Secure: true,
+ })
+}