示例#1
0
        public async Task RoleReadAndWrite()
        {
            LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);

            string name    = $"role_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
            LCACL  roleACL = new LCACL();

            roleACL.SetUserReadAccess(currentUser, true);
            roleACL.SetUserWriteAccess(currentUser, true);
            LCRole role = LCRole.Create(name, roleACL);

            role.AddRelation("users", currentUser);
            await role.Save();

            account = new Account();
            LCACL acl = new LCACL();

            acl.SetRoleReadAccess(role, true);
            acl.SetRoleWriteAccess(role, true);
            account.ACL = acl;
            await account.Save();

            Assert.IsTrue(acl.GetRoleReadAccess(role));
            Assert.IsTrue(acl.GetRoleWriteAccess(role));
        }
示例#2
0
        public async Task NewRole()
        {
            LCUser currentUser = await LCUser.Login("game", "play");

            LCACL acl = new LCACL();

            acl.PublicReadAccess = true;
            acl.SetUserWriteAccess(currentUser, true);
            string name = $"role_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
            LCRole role = LCRole.Create(name, acl);

            role.AddRelation("users", currentUser);
            await role.Save();
        }