1
0

Added namespace user rights

This commit is contained in:
konrad
2018-09-04 20:15:24 +02:00
committed by kolaente
parent 422662e3e1
commit f2758e239c
12 changed files with 179 additions and 4 deletions

View File

@ -66,6 +66,9 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error {
if models.IsErrUserAlreadyHasAccess(err) {
return echo.NewHTTPError(http.StatusBadRequest, "This user already has access to this list.")
}
if models.IsErrUserAlreadyHasNamespaceAccess(err) {
return echo.NewHTTPError(http.StatusBadRequest, "This user already has access to this namespace.")
}
if models.IsErrInvalidUserRight(err) {
return echo.NewHTTPError(http.StatusBadRequest, "The right is invalid.")
}

View File

@ -2,7 +2,6 @@ package crud
import (
"code.vikunja.io/api/models"
"fmt"
"github.com/labstack/echo"
"net/http"
)
@ -25,7 +24,6 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error {
err = c.CObject.Delete()
if err != nil {
fmt.Println(err)
if models.IsErrNeedToBeListAdmin(err) {
return echo.NewHTTPError(http.StatusForbidden, "You need to be the list admin to delete a list.")
}
@ -49,6 +47,10 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "This user does not have access to the list.")
}
if models.IsErrUserDoesNotHaveAccessToNamespace(err) {
return echo.NewHTTPError(http.StatusBadRequest, "This user does not have access to the namespace.")
}
return echo.NewHTTPError(http.StatusInternalServerError)
}