1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 22:29:41 +02:00

using all new permissions for securing spaces and documents

WIP
This commit is contained in:
Harvey Kandola 2017-09-18 13:02:15 +01:00
parent ef285c91de
commit 300b617583
51 changed files with 517 additions and 868 deletions

View file

@ -135,24 +135,24 @@ func (h *Handler) DocumentLinks(w http.ResponseWriter, r *http.Request) {
response.WriteJSON(w, l)
}
// BySpace is an endpoint that returns the documents in a given folder.
// BySpace is an endpoint that returns the documents for given space.
func (h *Handler) BySpace(w http.ResponseWriter, r *http.Request) {
method := "document.space"
ctx := domain.GetRequestContext(r)
folderID := request.Query(r, "folder")
spaceID := request.Query(r, "space")
if len(folderID) == 0 {
response.WriteMissingDataError(w, method, "folder")
if len(spaceID) == 0 {
response.WriteMissingDataError(w, method, "space")
return
}
if !space.CanViewSpace(ctx, *h.Store, folderID) {
if !space.CanViewSpace(ctx, *h.Store, spaceID) {
response.WriteForbiddenError(w)
return
}
documents, err := h.Store.Document.GetBySpace(ctx, folderID)
documents, err := h.Store.Document.GetBySpace(ctx, spaceID)
if len(documents) == 0 {
documents = []doc.Document{}