diff --git a/handlers/handlers.go b/handlers/handlers.go index 252228d..94dde96 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -15,15 +15,15 @@ func Admin() echo.HandlerFunc { func Index() echo.HandlerFunc { return func(c echo.Context) error { - sess, _ := session.Get(setting.SessionCookieName(), c) - - username := sess.Values["username"] - if username != nil { - return c.Redirect(http.StatusFound, "/home") - } - addHeaders(c) + if sess, _ := session.Get(setting.SessionCookieName(), c); sess != nil { + username := sess.Values["username"] + if username != nil { + return c.Redirect(http.StatusFound, "/home") + } + } + csrf := c.Get("csrf").(string) err := c.Render( diff --git a/handlers/signin.go b/handlers/signin.go index 92054de..39635a0 100644 --- a/handlers/signin.go +++ b/handlers/signin.go @@ -17,11 +17,11 @@ func Signin() echo.HandlerFunc { return func(c echo.Context) error { addHeaders(c) - sess, _ := session.Get(setting.SessionCookieName(), c) - - username := sess.Values["username"] - if username != nil { - return c.Redirect(http.StatusFound, "/home") + if sess, _ := session.Get(setting.SessionCookieName(), c); sess != nil { + username := sess.Values["username"] + if username != nil { + return c.Redirect(http.StatusFound, "/home") + } } return c.Render(