Skip to content

ACL for requesting user won't allow Read #1917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
avielfedida opened this issue May 26, 2016 · 2 comments
Closed

ACL for requesting user won't allow Read #1917

avielfedida opened this issue May 26, 2016 · 2 comments

Comments

@avielfedida
Copy link

Hi everyone, I'm using version 2.2.10, I followed this parse tutorial.

Where I got to the point where I have to execute something like:

Parse.Cloud.run('friend', {"friendId": "w5VCkWYnap"})

I've noticed that at the server, right about here:

roleQuery.first().then(function(role) {
        console.log(role); // Undefined?, WHAT!
        role.getUsers().add(userToFriend);
        return role.save();
    }).then(function() {
        response.success("Success!");    
    })

I get undefined, I've looked at the ACL and its fine, I execute Parse.Cloude.run via user that have ACL(Read/Write) for the object I'm trying to fetch, I even logged the request.user.id and its the id for the user that executes Parse.Cloude.run, so to rule out permissions I enabled for the role I was looking Public(Read/Write) and its WORKING?!, I don't get undefined anymore, everything works, what?, I don't know if something wasn't implemented yet or its just a bug, anyway if I was doing something wrong I'd be glad to know about it.

I haven't tested running the code from the client, the roleQuery is part of the cloud code script, moreover I haven't tested write but I believe its the same.

@JeremyPlease
Copy link
Contributor

Requests made from Parse Cloud Code don't assume the session of the requesting user. See issue #1729.

So, your code would become:

var sessionToken = request.user.getSessionToken();
roleQuery.first({ sessionToken: sessionToken }).then(function(role) {
    role.getUsers().add(userToFriend);
    return role.save(null, { sessionToken: sessionToken });
}).then(function() {
    response.success("Success!");    
}, function(error) {
    response.error(error);
});

@hramos
Copy link
Contributor

hramos commented May 26, 2016

@JeremyPlease's suggestion looks good to me. Closing as this is not a Parse Server issue.

@hramos hramos closed this as completed May 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants