Skip to content
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

Cloud Code unauthorized after update to 2.3.7 #3657

Closed
aaronfranco opened this issue Mar 22, 2017 · 1 comment
Closed

Cloud Code unauthorized after update to 2.3.7 #3657

aaronfranco opened this issue Mar 22, 2017 · 1 comment

Comments

@aaronfranco
Copy link

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
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

1 participant