~netlandish/gobwebs

176dfe03dd12db260e582f22fe293943894b7050 — Peter Sanchez 2 years ago 1b3fc62
Fixing redirect bug in AuthRequired middleware redirect
1 files changed, 2 insertions(+), 1 deletions(-)

M accounts/middleware.go
M accounts/middleware.go => accounts/middleware.go +2 -1
@@ 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)