Esempio n. 1
0
 public void RemoveMember(string aclObjectId, IAclMember member)
 {
     DB.Update <T>()
     .Match(a => a.ID == aclObjectId)
     .Modify(a => a.Unset(string.Format("acl.{0}.{1}", MemberList.readers.ToString("g"), member.Id)))
     .Modify(a => a.Unset(string.Format("acl.{0}.{1}", MemberList.admins.ToString("g"), member.Id)))
     .Execute();
 }
Esempio n. 2
0
        public bool AddMember(string aclObjectId, IAclMember member, MemberList type)
        {
            MemberList otherType = type == MemberList.admins ? MemberList.readers : MemberList.admins;

            MemberType memberType = (member as User) != null ? MemberType.user : MemberType.team;

            // TODO: Check to see if member is an owner, if so, don't do anything
            DB.Update <T>()
            .Match(t => t.Eq(a => a.ID, aclObjectId) &
                   t.Ne(a => a.acl.ownerId, member.Id))
            .Modify(a => a.Set(ACLMemberString(member.Id, type), memberType))
            .Modify(a => a.Unset(ACLMemberString(member.Id, otherType)))
            .Execute();

            return(true);
        }
Esempio n. 3
0
        public void RemoveMember(string id, string unMemberId, User subject)
        {
            if (!membershipInterface.IsAdmin(id, subject))
            {
                throw new NotAuthorized();
            }

            IAclMember unMember = userInterface.GetById(unMemberId);

            if (unMember == null)
            {
                unMember = teamInterface.GetById(unMemberId);
            }

            if (unMember == null)
            {
                return;
            }

            membershipInterface.RemoveMember(id, unMember);
        }
Esempio n. 4
0
        public bool AddReader(string id, string newAdminId, User subject)
        {
            if (!membershipInterface.IsAdmin(id, subject))
            {
                throw new NotAuthorized();
            }

            IAclMember newAdmin = userInterface.GetById(newAdminId);

            if (newAdmin == null)
            {
                newAdmin = teamInterface.GetById(newAdminId);
            }

            if (newAdmin == null)
            {
                return(false);
            }

            return(membershipInterface.AddMember(id, newAdmin, MemberList.readers));
        }