1
0
This commit is contained in:
konrad
2018-07-12 23:36:55 +02:00
committed by kolaente
parent c5888093fe
commit 7f7b243cbe
6 changed files with 30 additions and 105 deletions

View File

@ -4,6 +4,7 @@ import (
"git.kolaente.de/konrad/list/models"
"github.com/labstack/echo"
"net/http"
"strconv"
)
// GetListsByNamespaceID is the web handler to delete a namespace
@ -51,3 +52,31 @@ func GetListsByNamespaceID(c echo.Context) error {
}
return c.JSON(http.StatusOK, lists)
}
func getNamespace(c echo.Context) (namespace models.Namespace, err error) {
// Check if we have our ID
id := c.Param("id")
// Make int
namespaceID, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return
}
// Get the namespace
namespace, err = models.GetNamespaceByID(namespaceID)
if err != nil {
return
}
// Check if the user has acces to that namespace
user, err := models.GetCurrentUser(c)
if err != nil {
return
}
if !namespace.CanRead(&user) {
return
}
return
}