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/logout.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/logout.go')
-rw-r--r-- | pkg/webui/logout.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/webui/logout.go b/pkg/webui/logout.go new file mode 100644 index 0000000..6a281bb --- /dev/null +++ b/pkg/webui/logout.go @@ -0,0 +1,24 @@ +package webui + +import ( + "html/template" + "net/http" + + "git.adyxax.org/adyxax/tfstated/pkg/database" + "git.adyxax.org/adyxax/tfstated/pkg/model" +) + +var logoutTemplate = template.Must(template.ParseFS(htmlFS, "html/base.html", "html/logout.html")) + +func handleLogoutGET(db *database.DB) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + session := r.Context().Value(model.SessionContextKey{}) + err := db.DeleteSession(session.(*model.Session)) + if err != nil { + errorResponse(w, http.StatusInternalServerError, err) + return + } + unsetSesssionCookie(w) + render(w, logoutTemplate, http.StatusOK, nil) + }) +} |