Added namespace user rights
This commit is contained in:
@ -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.")
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -134,6 +134,13 @@ func RegisterRoutes(e *echo.Echo) {
|
||||
a.PUT("/namespaces/:namespace/teams", namespaceTeamHandler.CreateWeb)
|
||||
a.DELETE("/namespaces/:namespace/teams/:team", namespaceTeamHandler.DeleteWeb)
|
||||
|
||||
namespaceUserHandler := &crud.WebHandler{
|
||||
CObject: &models.NamespaceUser{},
|
||||
}
|
||||
a.GET("/namespaces/:namespace/users", namespaceUserHandler.ReadAllWeb)
|
||||
a.PUT("/namespaces/:namespace/users", namespaceUserHandler.CreateWeb)
|
||||
a.DELETE("/namespaces/:namespace/users/:user", namespaceUserHandler.DeleteWeb)
|
||||
|
||||
teamHandler := &crud.WebHandler{
|
||||
CObject: &models.Team{},
|
||||
}
|
||||
|
Reference in New Issue
Block a user