Search code examples
javascriptparse-platformparse-server

How to run Parse Cloud Code by a specific user?


How can call Parse.Cloud.run by specific user in javascript api?

Server code

Parse.Cloud.define('createChatRoom', async (req, res) => {
    if (req.user == null) {
        res.error({
            message: 'No request user',
        });
    }
    ...
}

Solution

  • You can input user's sessionToken to third parameter object is not expressed in official doc.

    Parse.Cloud.run(
        'createChatRoom', 
        { title: roomTitle }, 
        { sessionToken: user.getSessionToken() } // User specific user's session
    );