diff options
author | Julien Dessaux | 2025-01-13 10:11:20 +0100 |
---|---|---|
committer | Julien Dessaux | 2025-01-13 10:11:20 +0100 |
commit | 1292d189cf15dd7ea904d5f76dc9630514f175c4 (patch) | |
tree | 6aab0161136c1d53ba8d0ffe931d9810b1b9c419 /pkg/webui/sessions.go | |
parent | feat(tfstated): store created and updated timestamps for states (diff) | |
download | tfstated-1292d189cf15dd7ea904d5f76dc9630514f175c4.tar.gz tfstated-1292d189cf15dd7ea904d5f76dc9630514f175c4.tar.bz2 tfstated-1292d189cf15dd7ea904d5f76dc9630514f175c4.zip |
feat(webui): implement logout process
Diffstat (limited to 'pkg/webui/sessions.go')
-rw-r--r-- | pkg/webui/sessions.go | 24 |
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, + }) +} |