Add logout route
This commit is contained in:
parent
23e3e85251
commit
f4808eb4c5
2 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue