예제 #1
0
        public bool CanDelete(CosmosDocument entity)
        {
            if (entity.IsSystemType() || entity.Owner == GlobalDataSettings.SystemOwnerName)
            {
                return(false);
            }

            if (IsAdmin())
            {
                return(true);
            }

            return(entity.Owner == Id);
        }
예제 #2
0
        public bool CanUpdate(CosmosDocument entity, List <string> shares)
        {
            if (entity.Type == "account" && Id == entity.Id)
            {
                return(true);
            }

            if (IsAdmin())
            {
                return(true);
            }

            return(CanRead(entity, shares));
        }
예제 #3
0
        public bool CanRead(CosmosDocument entity, List <string> shares)
        {
            if (IsAdmin())
            {
                return(true);
            }

            var groups = GetGroups();

            if (entity.Owner == Id || shares.Contains(entity.Owner) || shares.Contains(entity.Id) || entity.Participants.Any(participant => participant.Id == Id))
            {
                return(true);
            }

            if (entity.Type == "account")
            {
                return(entity.GetPropertyValue <List <string> >("groups").Any(group => groups.Contains(group)));
            }

            return(false);
        }