go(logout): redir to /home if valid session exists
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2023-08-07 14:21:48 +02:00
parent 9dd5f05eb6
commit c8a48cd526
Signed by: wanderer
SSH Key Fingerprint: SHA256:MdCZyJ2sHLltrLBp0xQO0O1qTW9BT/xl5nXkDvhlMCI

@ -36,6 +36,13 @@ func Logout() echo.HandlerFunc {
return c.Redirect(http.StatusMovedPermanently, "/logout") return c.Redirect(http.StatusMovedPermanently, "/logout")
case c.Request().Method == "GET": case c.Request().Method == "GET":
sess, _ := session.Get(setting.SessionCookieName(), c)
if sess != nil {
if username := sess.Values["username"]; username != nil {
return c.Redirect(http.StatusSeeOther, "/home")
}
}
err := c.Render( err := c.Render(
http.StatusOK, http.StatusOK,
"logout.tmpl", "logout.tmpl",