添加用户以解析角色(Add a user to parse role)

编程入门 行业动态 更新时间:2024-10-26 22:27:46
添加用户以解析角色(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)

更多推荐

本文发布于:2023-08-05 08:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1431250.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:角色   用户   Add   role   parse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!