aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-03 13:24:46 +0100
committerSimon Ser <contact@emersion.fr>2019-12-03 13:24:46 +0100
commitf4808eb4c51f4f2a70b85ee7caaa4349e1b5689f (patch)
treefdd53b35c0c7bb750e785c47054e7c78ed5cda24
parent23e3e8525135507f5084c0a4627812d4c0083106 (diff)
downloadalps-f4808eb4c51f4f2a70b85ee7caaa4349e1b5689f.tar.gz
alps-f4808eb4c51f4f2a70b85ee7caaa4349e1b5689f.zip
Add logout route
-rw-r--r--public/mailbox.html2
-rw-r--r--server.go9
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>
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