Skip to content

Need master key perms to call request.user.fetch() in cloud code #750

Closed
@all-iver

Description

@all-iver

This code works on legacy Parse without using the master key. On Parse Server I need to send {useMasterKey: true} to the fetch() call to make it work. Shouldn't cloud code assume the permissions of the user making the call?

Environment Setup

A user that looks like this is logged in to our iOS app:

{
    "_id": "KJXlhIPK4R",
    "_rperm": [
        "KJXlhIPK4R",
        "role:Admin"
    ],
    "_wperm": [
        "KJXlhIPK4R"
    ],
    ...
}

Steps to reproduce

Have the user call a cloud code method that looks like this:

Parse.Cloud.define('someMethod', function(request, response) {
    request.user.fetch().then(function() {
        // success
    }, 
    function() {
        response.error('Error getting user data.');
    });
});

Logs/Trace

GET /parse/classes/_User/KJXlhIPK4R { 'user-agent': 'node-XMLHttpRequest, Parse/js1.7.1 (NodeJS 5.0.0)',
  accept: '*/*',
  'content-type': 'text/plain',
  host: 'localhost:1337',
  'content-length': '154',
  connection: 'close' } {}
error: ParseError { code: 101, message: 'Object not found.' }
error: ParseError { code: 141, message: 'Error getting user data.' }

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