Added methods to give users access to a list
This commit is contained in:
@ -63,6 +63,13 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "This user is already a member of that team.")
|
||||
}
|
||||
|
||||
if models.IsErrUserAlreadyHasAccess(err) {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "This user already has access to this list.")
|
||||
}
|
||||
if models.IsErrInvalidUserRight(err) {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "The right is invalid.")
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,10 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
||||
|
||||
lists, err := c.CObject.ReadAll(¤tUser)
|
||||
if err != nil {
|
||||
if models.IsErrNeedToHaveListReadAccess(err) {
|
||||
return echo.NewHTTPError(http.StatusForbidden, "You need to have read access to this list.")
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, "An error occured.")
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,13 @@ func RegisterRoutes(e *echo.Echo) {
|
||||
a.PUT("/lists/:list/teams", listTeamHandler.CreateWeb)
|
||||
a.DELETE("/lists/:list/teams/:team", listTeamHandler.DeleteWeb)
|
||||
|
||||
listUserHandler := &crud.WebHandler{
|
||||
CObject: &models.ListUser{},
|
||||
}
|
||||
a.GET("/lists/:list/users", listUserHandler.ReadAllWeb)
|
||||
a.PUT("/lists/:list/users", listUserHandler.CreateWeb)
|
||||
a.DELETE("/lists/:list/users/:user", listUserHandler.DeleteWeb)
|
||||
|
||||
namespaceHandler := &crud.WebHandler{
|
||||
CObject: &models.Namespace{},
|
||||
}
|
||||
|
Reference in New Issue
Block a user