diff --git a/models/collaborative_area/collaborative_area.go b/models/collaborative_area/collaborative_area.go index 2d883be..85b2454 100644 --- a/models/collaborative_area/collaborative_area.go +++ b/models/collaborative_area/collaborative_area.go @@ -83,9 +83,6 @@ func (ao *CollaborativeArea) VerifyAuth(request *tools.APIRequest) bool { } } } - if ao.CreatorID == request.PeerID { - return true - } } return ao.AbstractObject.VerifyAuth(request) } diff --git a/models/resources/workflow.go b/models/resources/workflow.go index 7ffda78..b191958 100644 --- a/models/resources/workflow.go +++ b/models/resources/workflow.go @@ -26,9 +26,6 @@ func (r *WorkflowResource) GetType() string { func (d *WorkflowResource) Trim() { /* EMPTY */ } -func (abs *WorkflowResource) VerifyAuth(request *tools.APIRequest) bool { - return true -} func (w *WorkflowResource) SetAllowedInstances(request *tools.APIRequest) { /* EMPTY */ } diff --git a/models/utils/common.go b/models/utils/common.go index 4329c05..1637078 100644 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -31,7 +31,7 @@ func GenericStoreOne(data DBObject, a Accessor) (DBObject, int, error) { }, } if a.ShouldVerifyAuth() && !data.VerifyAuth(a.GetRequest()) { - return nil, 403, errors.New("you are not allowed to access this collaborative area") + return nil, 403, errors.New("you are not allowed to access : " + a.GetType().String()) } if cursor, _, _ := a.Search(&f, "", data.IsDrafted()); len(cursor) > 0 { return nil, 409, errors.New(a.GetType().String() + " with name " + data.GetName() + " already exists") @@ -52,14 +52,14 @@ func GenericStoreOne(data DBObject, a Accessor) (DBObject, int, error) { func GenericDeleteOne(id string, a Accessor) (DBObject, int, error) { res, code, err := a.LoadOne(id) if !res.CanDelete() { - return nil, 403, errors.New("you are not allowed to delete this collaborative area") + return nil, 403, errors.New("you are not allowed to delete :" + a.GetType().String()) } if err != nil { a.GetLogger().Error().Msg("Could not retrieve " + id + " to db. Error: " + err.Error()) return nil, code, err } if a.ShouldVerifyAuth() && !res.VerifyAuth(a.GetRequest()) { - return nil, 403, errors.New("you are not allowed to access this collaborative area") + return nil, 403, errors.New("you are not allowed to access " + a.GetType().String()) } _, code, err = mongo.MONGOService.DeleteOne(id, a.GetType().String()) if err != nil { @@ -78,12 +78,12 @@ func GenericUpdateOne(set DBObject, id string, a Accessor, new DBObject) (DBObje } ok, newSet := r.CanUpdate(set) if !ok { - return nil, 403, errors.New("you are not allowed to delete this collaborative area") + return nil, 403, errors.New("you are not allowed to delete :" + a.GetType().String()) } set = newSet r.UpToDate(a.GetUser(), a.GetPeerID(), false) if a.ShouldVerifyAuth() && !r.VerifyAuth(a.GetRequest()) { - return nil, 403, errors.New("you are not allowed to access this collaborative area") + return nil, 403, errors.New("you are not allowed to access :" + a.GetType().String()) } change := set.Serialize(set) // get the changes loaded := r.Serialize(r) // get the loaded object @@ -108,7 +108,7 @@ func GenericLoadOne[T DBObject](id string, f func(DBObject) (DBObject, int, erro } res_mongo.Decode(&data) if a.ShouldVerifyAuth() && !data.VerifyAuth(a.GetRequest()) { - return nil, 403, errors.New("you are not allowed to access this collaborative area") + return nil, 403, errors.New("you are not allowed to access :" + a.GetType().String()) } return f(data) }