From 89083f2ef44262e103081fcb146c4e7385236c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ron=20Nosz=C3=A1ly?= Date: Mon, 2 Sep 2024 20:57:00 +0200 Subject: [PATCH] fix #120 --- internal/web/handlers/user/profile/middleware.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/web/handlers/user/profile/middleware.go b/internal/web/handlers/user/profile/middleware.go index 03ddb7e..9e8566f 100644 --- a/internal/web/handlers/user/profile/middleware.go +++ b/internal/web/handlers/user/profile/middleware.go @@ -1,10 +1,12 @@ package profile import ( - "github.com/mraron/njudge/internal/web/templates" + "errors" "net/http" "net/url" + "github.com/mraron/njudge/internal/web/templates" + "github.com/labstack/echo/v4" "github.com/mraron/njudge/internal/njudge" ) @@ -27,6 +29,9 @@ func SetProfileMiddleware(u njudge.Users) echo.MiddlewareFunc { user, err := u.GetByName(c.Request().Context(), name) if err != nil { + if errors.Is(err,njudge.ErrorUserNotFound) { + return echo.NewHTTPError(http.StatusNotFound, err.Error() ) + } return err }