diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2018-12-30 06:34:30 -0500 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2018-12-30 06:34:30 -0500 |
| commit | 9c959b259c25a591be9ae26caac0a0a4467f7720 (patch) | |
| tree | 7fd8f1fc45817a5aa8766e10ea37e12e015d0c04 /main.go | |
| parent | 1ed8283df70c5c2f597821fd318cbda89d2eb7ea (diff) | |
| download | id-9c959b259c25a591be9ae26caac0a0a4467f7720.tar.gz | |
Improve logout
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -87,13 +87,17 @@ func (app *App) loginHandler(w http.ResponseWriter, r *http.Request) { } func (app *App) logoutHandler(w http.ResponseWriter, r *http.Request) { - c := http.Cookie{ - Name: "id", - Value: "", - Domain: "." + app.Domain, - MaxAge: 0, + if s, ok := app.validate(r); ok { + // should we save old sessions in another table? + app.DeleteSession(s.Id) + c := http.Cookie{ + Name: "id", + Value: "", + Domain: "." + app.Domain, + MaxAge: -1, + } + http.SetCookie(w, &c) } - http.SetCookie(w, &c) http.Redirect(w, r, "/login", http.StatusSeeOther) } |
