Skip to content

Can not set ACL in cloud code for new User #701

Closed
@sanergulec

Description

@sanergulec

Hello, I try to set the ACL of a new created user that has the read and write permission only by the user. For objects in the other tables I do not have any problem setting the ACL as I am using "beforeSave". But for the user I can not use the "beforeSave" as the user is not created yet. I tried lots of different combinations, but couldn't make it work. The last that I tried is the code below. But it didn't worked either.
Maybe when the "afterSave" function starts in the cloud, the user is not created yet and for this reason the ID can not be set as permission, I don't know. Is there anyone who knows how the set the ACL for a new user only permission to that user?

Parse.Cloud.afterSave(Parse.User, function(req) {

    if (!req.user.existed()) {

    var acl = new Parse.ACL();
    acl.setReadAccess(req.user, true);
    acl.setWriteAccess(req.user, true);
    req.user.setACL(acl);
    req.user.save();

    }

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions