添加用户以解析角色(Add a user to parse role)
我正在尝试创建一个新用户并将其添加到已经存在的ParseRole,但是我得到了ParseException:在执行await parseRole.SaveAsync()之后找不到更新的对象 ; 。
我检查了Parse网站,并保存了角色和用户(c#代码返回的ID是正确的),但角色没有该用户。
[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(); }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 problem was I didn't set the ACL for my roles to allow write access to the logged user (or public, in case of my unit test)
更多推荐
发布评论