Call cloud function from another cloud function

hello guys i have function A that calls function B…
how can i restrict users from calling function B on their device … thanks

If you never plan on exposing function B to the users, you can use a standard javascript function, such as:

Parse.Cloud.define('functionA', req => {
  // do things here
  functionB(req);
});
function functionB(req) {
  // function B can only be called from this javascript file
}

Or, you can restrict functionB, such as:

// V4.4.0 Cloud Validators:
Parse.Cloud.define('functionB', req => {
  // any code below here will only run if a masterKey is provided
}, {
  requireMaster: true
});

// Prior to V4.4.0
Parse.Cloud.define('functionB', req => {
  if (!req.master) {
    throw new Parse.Error(141, 'Unauthorized');
  }
  // any code below here will only run if a masterKey is provided
});

And then call from functionA using Parse.Cloud.run('functionB', params, {useMasterKey:true});

4 Likes