简体   繁体   English

更新查询对象的解析ACL

[英]Update Parse ACL on queried object

In my iOS app I am making a PFObject and saving it to Parse. 在我的iOS应用中,我正在制作PFObject并将其保存到Parse。 Later, a user's account is created (which didn't exist before), and tries to modify it but can't because the PFObjects's ACL wasn't set to allow that user to have permission. 后来,创建了一个用户帐户(该帐户以前不存在),并尝试对其进行修改,但是由于PFObjects的ACL未设置为允许该用户具有权限而无法进行修改。 How can I modify the ACL of an existing object in Parse to allow this user to have access? 如何修改Parse中现有对象的ACL以允许该用户访问? I do not want to allow public write access. 希望让公众写访问。

The following code prints Success! 以下代码显示Success! if given the right code query parameter, but when I check the ACL in Parse it has not been updated at all. 如果给出正确的code查询参数,但是当我在Parse中检查ACL时,它根本没有更新。

let query = PFQuery(className: "Bike")
query.whereKey("bikeID", equalTo: code)
query.findObjectsInBackground { (objects: [PFObject]?, error: Error?) in
    guard let obj = objects?[0], error == nil else {
        print("Error")
        return
    }
    obj.acl?.setWriteAccess(true, for: PFUser.current()!)
    obj.saveInBackground { (success: Bool, error: Error?) in
        if error != nil {
            print(error!.localizedDescription)
        }
        else {
            print("Success!")
        }
    }
}

This post seems to suggest that the ACL cannot be changed through my app's Swift code. 这篇文章似乎暗示无法通过我的应用程序的Swift代码更改ACL。

如果知道要授予访问权限的对象,则可以在User类的CloudCode afterSave挂钩中更改其ACL:在afterSave ,测试是否已创建用户(以避免为以后的保存请求重做此工作) ,然后查找对象并使用主密钥设置访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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