From f4808eb4c51f4f2a70b85ee7caaa4349e1b5689f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 3 Dec 2019 13:24:46 +0100 Subject: Add logout route --- public/mailbox.html | 2 ++ server.go | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/public/mailbox.html b/public/mailbox.html index 282f462..c4ff097 100644 --- a/public/mailbox.html +++ b/public/mailbox.html @@ -2,6 +2,8 @@

koushin

+Logout +

{{.Mailbox.Name}}

Mailboxes:

diff --git a/server.go b/server.go index 4bdd15b..c6d61e8 100644 --- a/server.go +++ b/server.go @@ -238,6 +238,15 @@ func New(imapURL string) *echo.Echo { e.GET("/login", handleLogin) e.POST("/login", handleLogin) + e.GET("/logout", func(ectx echo.Context) error { + ctx := ectx.(*context) + if err := ctx.conn.Logout(); err != nil { + return err + } + ctx.setToken("") + return ctx.Redirect(http.StatusFound, "/login") + }) + e.Static("/assets", "public/assets") return e -- cgit v1.2.3