From 176dfe03dd12db260e582f22fe293943894b7050 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Fri, 5 Aug 2022 17:25:44 -0600 Subject: [PATCH] Fixing redirect bug in AuthRequired middleware redirect --- accounts/middleware.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts/middleware.go b/accounts/middleware.go index adbdfe6..ce9cc17 100644 --- a/accounts/middleware.go +++ b/accounts/middleware.go @@ -58,7 +58,8 @@ func AuthRequired() echo.MiddlewareFunc { return fmt.Errorf("Context.User not set. Must call AuthMiddleware first") } if !gctx.User.IsAuthenticated() { - next := fmt.Sprintf("%s?next=%s", c.Echo().Reverse("accounts:login"), c.Path()) + req := c.Request() + next := fmt.Sprintf("%s?next=%s", c.Echo().Reverse("accounts:login"), req.URL.Path) return c.Redirect(http.StatusMovedPermanently, next) } return next(gctx) -- 2.45.2