mirror of
https://github.com/documize/community.git
synced 2025-07-19 13:19:43 +02:00
refined category permission checks
This commit is contained in:
parent
4d989e2497
commit
3a9675eb14
11 changed files with 149 additions and 22 deletions
|
@ -273,9 +273,9 @@ func (h *Handler) GetUserSpacePermissions(w http.ResponseWriter, r *http.Request
|
|||
response.WriteJSON(w, record)
|
||||
}
|
||||
|
||||
// GetCategoryPermissions returns user permissions for given category.
|
||||
func (h *Handler) GetCategoryPermissions(w http.ResponseWriter, r *http.Request) {
|
||||
method := "space.GetCategoryPermissions"
|
||||
// GetCategoryViewers returns user permissions for given category.
|
||||
func (h *Handler) GetCategoryViewers(w http.ResponseWriter, r *http.Request) {
|
||||
method := "space.GetCategoryViewers"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
categoryID := request.Param(r, "categoryID")
|
||||
|
@ -296,6 +296,29 @@ func (h *Handler) GetCategoryPermissions(w http.ResponseWriter, r *http.Request)
|
|||
response.WriteJSON(w, u)
|
||||
}
|
||||
|
||||
// GetCategoryPermissions returns user permissions for given category.
|
||||
func (h *Handler) GetCategoryPermissions(w http.ResponseWriter, r *http.Request) {
|
||||
method := "space.GetCategoryPermissions"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
categoryID := request.Param(r, "categoryID")
|
||||
if len(categoryID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "categoryID")
|
||||
return
|
||||
}
|
||||
|
||||
u, err := h.Store.Permission.GetCategoryPermissions(ctx, categoryID)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
response.WriteServerError(w, method, err)
|
||||
return
|
||||
}
|
||||
if len(u) == 0 {
|
||||
u = []permission.Permission{}
|
||||
}
|
||||
|
||||
response.WriteJSON(w, u)
|
||||
}
|
||||
|
||||
// SetCategoryPermissions persists specified category permissions
|
||||
func (h *Handler) SetCategoryPermissions(w http.ResponseWriter, r *http.Request) {
|
||||
method := "permission.SetCategoryPermissions"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue