Added methods to revoke a users access to a list

This commit is contained in:
konrad 2018-08-30 18:52:12 +02:00 committed by kolaente
parent b1c3e92f66
commit efaa277751
Signed by untrusted user who does not match committer: konrad
GPG key ID: F40E70337AB24C9B
5 changed files with 87 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package crud
import (
"code.vikunja.io/api/models"
"fmt"
"github.com/labstack/echo"
"net/http"
)
@ -24,7 +25,7 @@ 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.")
}
@ -41,6 +42,10 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "You cannot delete the last member of a team.")
}
if models.IsErrUserDoesNotHaveAccessToList(err) {
return echo.NewHTTPError(http.StatusBadRequest, "This user does not have access to the list.")
}
return echo.NewHTTPError(http.StatusInternalServerError)
}