diff --git a/handlers/handlers.go b/handlers/handlers.go index 8efc5a0..794a1e5 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -169,7 +169,7 @@ func Signin() echo.HandlerFunc { log.Info("got session") // if err := session.Valid(); err == nil && session.Expires.After(time.Now()) { if err := session.Valid(); err == nil { - c.Redirect(302, "/home") + return c.Redirect(302, "/home") } else { log.Warn("invalid (or expired) session", "error", err.Error()) } @@ -212,18 +212,14 @@ func SigninPost(client *ent.Client) echo.HandlerFunc { } else { log.Info("username was not set, returning to /signin") - c.Redirect(302, "/signin") - - return nil + return c.Redirect(302, "/signin") } if passwd := c.Request().FormValue("password"); passwd != "" { password = passwd } else { log.Info("password was not set, returning to /signin") - c.Redirect(302, "/signin") - - return nil + return c.Redirect(302, "/signin") } ctx := context.WithValue(context.Background(), "logger", log) @@ -232,7 +228,7 @@ func SigninPost(client *ent.Client) echo.HandlerFunc { if usr.Password != password { log.Warn("wrong user credentials, redirecting to /signin") - c.Redirect(302, "/signin") + return c.Redirect(302, "/signin") } } else { // just log the error instead of returning it to the user and @@ -244,9 +240,7 @@ func SigninPost(client *ent.Client) echo.HandlerFunc { http.StatusText(http.StatusUnauthorized)+" "+err.Error(), )) - c.Redirect(302, "/signin") - - return nil + return c.Redirect(302, "/signin") } secure := c.Request().URL.Scheme == "https" @@ -261,9 +255,7 @@ func SigninPost(client *ent.Client) echo.HandlerFunc { } c.SetCookie(cookieSession) - c.Redirect(301, "/home") - - return nil + return c.Redirect(301, "/home") } } @@ -279,7 +271,7 @@ func Signup() echo.HandlerFunc { log.Info("got session") // if err := session.Valid(); err == nil && session.Expires.After(time.Now()) { if err := session.Valid(); err == nil { - c.Redirect(302, "/home") + return c.Redirect(302, "/home") } else { log.Warn("invalid (or expired) session", "error", err.Error()) } @@ -350,9 +342,7 @@ func SignupPost(client *ent.Client) echo.HandlerFunc { } else { log.Info("user registration: username was not set, returning to /signup") - c.Redirect(302, "/signup") - - return nil + return c.Redirect(302, "/signup") } secure := c.Request().URL.Scheme == "https" @@ -366,9 +356,7 @@ func SignupPost(client *ent.Client) echo.HandlerFunc { } c.SetCookie(cookieSession) - c.Redirect(301, "/home") - - return nil + return c.Redirect(301, "/home") } } @@ -437,9 +425,7 @@ func Logout() echo.HandlerFunc { if errors.Is(err, http.ErrNoCookie) { log.Info("nobody to log out, redirecting to /signin") - c.Redirect(302, "/signin") - - return nil + return c.Redirect(302, "/signin") } log.Warnf("error: %q", err)