From 83337a24ac5102ae953231de42e90bdd403d726e Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 23 Jan 2019 15:21:21 +0100 Subject: [PATCH] Fixed logging the current user if forbidden --- handler/create.go | 2 +- handler/delete.go | 3 +-- handler/read_one.go | 3 +-- handler/update.go | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/handler/create.go b/handler/create.go index 57c288b..acd2227 100644 --- a/handler/create.go +++ b/handler/create.go @@ -45,7 +45,7 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error { // Check rights if !currentStruct.CanCreate(currentAuth) { - getLogger(ctx).Noticef("Tried to create while not having the rights for it", currentAuth) + getLogger(ctx).Noticef("Tried to create while not having the rights for it (User: %v)", currentAuth) return echo.NewHTTPError(http.StatusForbidden) } diff --git a/handler/delete.go b/handler/delete.go index 82a75f6..51da07a 100644 --- a/handler/delete.go +++ b/handler/delete.go @@ -18,7 +18,6 @@ package handler import ( "code.vikunja.io/web" "github.com/labstack/echo" - "github.com/op/go-logging" "net/http" ) @@ -44,7 +43,7 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError) } if !currentStruct.CanDelete(currentAuth) { - getLogger(ctx).Noticef("Tried to delete while not having the rights for it", currentAuth) + getLogger(ctx).Noticef("Tried to delete while not having the rights for it (User: %v)", currentAuth) return echo.NewHTTPError(http.StatusForbidden) } diff --git a/handler/read_one.go b/handler/read_one.go index 147e3e2..8a524df 100644 --- a/handler/read_one.go +++ b/handler/read_one.go @@ -18,7 +18,6 @@ package handler import ( "code.vikunja.io/web" "github.com/labstack/echo" - "github.com/op/go-logging" "net/http" ) @@ -46,7 +45,7 @@ func (c *WebHandler) ReadOneWeb(ctx echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, "Could not determine the current user.") } if !currentStruct.CanRead(currentAuth) { - getLogger(ctx).Noticef("Tried to read one while not having the rights for it", currentAuth) + getLogger(ctx).Noticef("Tried to read one while not having the rights for it (User: %v)", currentAuth) return echo.NewHTTPError(http.StatusForbidden, "You don't have the right to see this") } diff --git a/handler/update.go b/handler/update.go index 2dc19dd..9dfd6f9 100644 --- a/handler/update.go +++ b/handler/update.go @@ -18,7 +18,6 @@ package handler import ( "code.vikunja.io/web" "github.com/labstack/echo" - "github.com/op/go-logging" "net/http" ) @@ -45,7 +44,7 @@ func (c *WebHandler) UpdateWeb(ctx echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, "Could not determine the current user.") } if !currentStruct.CanUpdate(currentAuth) { - getLogger(ctx).Noticef("Tried to update while not having the rights for it", currentAuth) + getLogger(ctx).Noticef("Tried to update while not having the rights for it (User: %v)", currentAuth) return echo.NewHTTPError(http.StatusForbidden) }