diff options
author | Simon Ser <contact@emersion.fr> | 2019-12-03 13:24:46 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-12-03 13:24:46 +0100 |
commit | f4808eb4c51f4f2a70b85ee7caaa4349e1b5689f (patch) | |
tree | fdd53b35c0c7bb750e785c47054e7c78ed5cda24 | |
parent | 23e3e8525135507f5084c0a4627812d4c0083106 (diff) | |
download | alps-f4808eb4c51f4f2a70b85ee7caaa4349e1b5689f.tar.gz alps-f4808eb4c51f4f2a70b85ee7caaa4349e1b5689f.zip |
Add logout route
-rw-r--r-- | public/mailbox.html | 2 | ||||
-rw-r--r-- | server.go | 9 |
2 files changed, 11 insertions, 0 deletions
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 @@ <h1>koushin</h1> +<a href="/logout">Logout</a> + <h2>{{.Mailbox.Name}}</h2> <p>Mailboxes:</p> @@ -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 |