diff --git a/models/collaborative_area/collaborative_area.go b/models/collaborative_area/collaborative_area.go index 77f3b1b..2d883be 100644 --- a/models/collaborative_area/collaborative_area.go +++ b/models/collaborative_area/collaborative_area.go @@ -33,7 +33,7 @@ type CollaborativeArea struct { Attributes map[string]interface{} `json:"attributes,omitempty" bson:"attributes,omitempty"` // Attributes is the attributes of the workspace (TODO) Workspaces []string `json:"workspaces" bson:"workspaces"` // Workspaces is the workspaces of the workspace Workflows []string `json:"workflows" bson:"workflows"` // Workflows is the workflows of the workspace - AllowedPeersGroup map[string][]string `json:"allowed_peers_group,omitempty" bson:"allowed_peers_group,omitempty"` // AllowedPeersGroup is the group of allowed peers + AllowedPeersGroup map[string][]string `json:"allowed_peers_group" bson:"allowed_peers_group"` // AllowedPeersGroup is the group of allowed peers Rules []string `json:"rules" bson:"rules,omitempty"` // Rules is the rules of the workspace SharedRules []*rule.Rule `json:"shared_rules,omitempty" bson:"-"` // SharedRules is the shared rules of the workspace @@ -83,6 +83,9 @@ func (ao *CollaborativeArea) VerifyAuth(request *tools.APIRequest) bool { } } } + if ao.CreatorID == request.PeerID { + return true + } } return ao.AbstractObject.VerifyAuth(request) } diff --git a/models/utils/common.go b/models/utils/common.go index 4a34cd5..8d91216 100644 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -17,7 +17,7 @@ type Owner struct { func GenericStoreOne(data DBObject, a Accessor) (DBObject, int, error) { data.GenerateID() data.StoreDraftDefault() - data.UpToDate(a.GetUser(), true) + data.UpToDate(a.GetPeerID(), true) f := dbs.Filters{ Or: map[string][]dbs.Filter{ "abstractresource.abstractobject.name": {{ @@ -81,7 +81,7 @@ func GenericUpdateOne(set DBObject, id string, a Accessor, new DBObject) (DBObje return nil, 403, errors.New("you are not allowed to delete this collaborative area") } set = newSet - r.UpToDate(a.GetUser(), false) + r.UpToDate(a.GetPeerID(), false) if a.ShouldVerifyAuth() && !r.VerifyAuth(a.GetRequest()) { return nil, 403, errors.New("you are not allowed to access this collaborative area") }