From c8a48cd526261a922438cdad49a8800f565f61b6 Mon Sep 17 00:00:00 2001 From: surtur Date: Mon, 7 Aug 2023 14:21:48 +0200 Subject: [PATCH] go(logout): redir to /home if valid session exists --- handlers/logout.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/handlers/logout.go b/handlers/logout.go index e6e2339..ab4de1f 100644 --- a/handlers/logout.go +++ b/handlers/logout.go @@ -36,6 +36,13 @@ func Logout() echo.HandlerFunc { return c.Redirect(http.StatusMovedPermanently, "/logout") 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( http.StatusOK, "logout.tmpl",