我目前遇到的问题是用户可以访问我的应用中的其他用户的对象.
我知道当用户在已经登录到应用程序时创建对象时如何设置ACL,但我不知道如何为注册的人设置ACL.当我设置导航标题以显示用户的[“BusinessName”]列时,我从另一个创建的用户列中收到商家名称….感谢您的帮助!非常感激!
@IBAction func signupFinalButton(sender: AnyObject) { var newUser = PFUser() newUser.username = username newUser.password = password newUser.email = email newUser["FirstName"] = firstName newUser["LastName"] = lastName newUser["BusinessName"] = businessName newUser["City"] = city newUser["State"] = state // This isn't seeming to work... newUser.ACL = PFACL(user: PFUser.currentUser()!) or this newUser.ACL = PFACL(user: PFUser()) newUser.signUpInBackgroundWithBlock({ (succeed,error) -> Void in
func navTitle () { var user = PFUser.currentUser() var query = PFQuery(className:"_User") query.findobjectsInBackgroundWithBlock { (objects: [AnyObject]?,error: NSError?) -> Void in if error == nil { if let objects = objects as? [PFObject] { for object in objects { self.homeScreen.title = object["BusinessName"] as! String? } }else { self.homeScreen.title = "Home" }
解决方法
您需要在signUp完成后设置ACL.
所以在委托方法中,
func signUpViewController(signUpController: PFSignUpViewController,didSignUpUser user: PFUser) // set the ACL for the newly created user newUser.ACL = PFACL(user: PFUser.currentUser()!) //Then you can save the user,ie saveEventaully
如果您没有使用PFSignUpViewController – 只需在signUpInBackgroundWithBlock的代码块中设置ACL,则在设置后调用save.
当您想要创建角色时,这是相同的,用户需要已经存在.
let role = PFRole(name: user.objectId!,acl: roleACL) role.users.addobject(user)
首次学习解析时,我建议通过this method创建新用户.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。