简体   繁体   中英

Add a user to parse role

I'm trying to create a new user and adding it to an already existing ParseRole, but i'm getting the ParseException: object not found for update after performing await parseRole.SaveAsync(); .

I checked in the Parse website and both the Role and User are saved (the ids returned by c# code are correct), but the Role hasn't that user.

        [TestMethod]
        public async Task CanCreateCustomer()
        {
            var customer = ParseObject.Create<ApplicationUser>();
            customer.FirstName = GetRandom.FirstName();
            customer.LastName = GetRandom.LastName();
            customer.Password = "123";
            customer.Username = customer.GetUserName();

            Assert.IsNull(customer.ObjectId);
            await customer.SignUpAsync();

            Assert.IsNotNull(customer.ObjectId);
            var parseRole = await ParseRole.Query.Where(x => x.Name == Roles.CustomerRole).FirstAsync();
            parseRole.Users.Add(customer);
            await parseRole.SaveAsync();
        }

问题是我没有为角色设置ACL来允许对登录用户(或在进行单元测试的情况下为公共用户)进行写访问

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM