Skip to content

Cloud Code unauthorized after update to 2.3.7 #3657

Closed
@aaronfranco

Description

@aaronfranco

Issue Description

I updated to the latest version and now my cloud code function returns unauthorized. It was fine before the update.

Steps to reproduce

Parse.Cloud.define('getUserRole', function(req, res) {
  var adminRoleQuery = new Parse.Query(Parse.Role);
  adminRoleQuery.equalTo('users', req.user);
  adminRoleQuery.first().then(function(result){
    console.log(result);
    res.success(result.getName());
  }, function(err){
    res.error(err);
  });
})

Expected Results

This function should return the role of the user that is making the request.

Actual Outcome

The function returns unauthorized.

Environment Setup

var api = new ParseServer({
  databaseURI: process.env.DB_URL,
  verifyUserEmail: process.env.VERIFY_EMAIL,
  publicServerURL: process.env.EMAIL_URL ,
  appName: process.env.APP_NAME ,
  enableAnonymousUsers: false,
  mountPath: "/",
  emailAdapter: sesServer,
  cloud: process.env.CLOUD_CODE ,
  appId: process.env.APP_ID,
  fileKey: process.env.FILE_KEY,
  filesAdapter:s3Adapter,
  masterKey: process.env.MASTER_KEY,
  clientKey: process.env.CLIENT_KEY,
  restAPIKey: process.env.REST_KEY,
  javascriptKey: process.env.JS_KEY,
  dotNetKey: process.env.DOT_NET_KEY || null,
  serverURL: process.env.CC_SERVER_URL,
  push: pushObj
});

The server is running locally or remote and the database is hosted in a remote location.

Logs/Trace

error: Failed running cloud function getUserRole for user 86B4NyZpye with:
  Input: {}
  Error: {"code":141,"message":{"message":"unauthorized"}} functionName=getUserRole, code=141, code=undefined, message=unauthorized, , user=86B4NyZpye
error: Error generating response. ParseError {
  code: 141,
  message: ParseError { code: undefined, message: 'unauthorized' } } code=141, code=undefined, message=unauthorized
error: ParseError { code: undefined, message: 'unauthorized' } code=141, code=undefined, message=unauthorized
Got Request

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