Fixed logging the current user if forbidden

This commit is contained in:
kolaente 2019-01-23 15:21:21 +01:00
parent b4a943dba1
commit 83337a24ac
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 4 additions and 7 deletions

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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")
}

View File

@ -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)
}