Parse Server Cloud Code Setting ACL -
i try set acls code below, in mongolab database not see acl settings. doing wrong in code? not find tutorial cloud code examples.
parse.cloud.aftersave('_user', function(req) { var user = req.user; var acl = new parse.acl(); acl.setreadaccess(req.user, true); acl.setwriteaccess(req.user, true); user.setacl(acl); user.save(); }); parse.cloud.aftersave('usersetting', function(req) { var userset = req.object; var acl = new parse.acl(); acl.setreadaccess(parse.user.current().id, true); acl.setwriteaccess(parse.user.current().id, true); userset.setacl(acl); userset.save(); });
i figured out code below. problem was trying use "aftersave" method while trying adding acl requested object, however, acl should added before saving, or if should done after saving, object should retrieved again , acl should added.
parse.cloud.beforesave('usersetting', function(req, res) { var acl = new parse.acl(); acl.setreadaccess(req.user, true); acl.setwriteaccess(req.user, true); req.object.setacl(acl); res.success(); });
Comments
Post a Comment