You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Successfully reproduced this in both my env and parse-server-example, so I doubt this is an issue with our own setup. The following setup/reproduction/log are on a newly cloned parse-server-example.
A sessionToken is included when calling cloud_function_2 from cloud_function_1, but req.user is still undefined in cloud_function_2.
I've previously submitted similar (and I think related) issue #1404, and was advised that I should have revocable session enabled. But this also happens when cloud_function_1 is called by the iOS client that has it enabled [PFUser enableRevocableSessionInBackground].
Please note when cloud_function_2 is directly called by the client, req.user exists with correct token.
// test_session file
#!/usr/bin/env node
varAPP_ID=process.env.APP_ID||"myAppId";varJAVASCRIPT_KEY=process.env.JAVASCRIPT_KEY||"myJavascriptKey";varParse=require('parse/node');Parse.initialize(APP_ID,JAVASCRIPT_KEY);Parse.serverURL=process.env.SERVER_URL||"http://localhost:1337/parse";console.log("test_session started");varnow=newDate();varusername=now.valueOf().toString();varuser=newParse.User();user.set("username",username);user.set("password","my pass");user.set("email",username+"@example.com");console.log("signing up user "+now.valueOf());user.signUp().then(function(user){console.log("calling cloud_function_1 with session token: "+user.getSessionToken());Parse.Cloud.run("cloud_function_1",null,{sessionToken: user.getSessionToken()})},function(error){console.log(error);})
// main.js fileParse.Cloud.define("cloud_function_1",function(req,res){console.log("\ncloud_function_1 was called by user: "+JSON.stringify(req.user));console.log("\ncalling cloud_function_2 from cloud_function_1 using sessionToken: "+req.user.getSessionToken());Parse.Cloud.run("cloud_function_2",null,{sessionToken: req.user.getSessionToken}).then(function(){res.success()},function(error){res.error(error);});})Parse.Cloud.define("cloud_function_2",function(req,res){console.log("\ncloud_function_2 was called by user: "+JSON.stringify(req.user));varresponse=req.user ? req.user.getSessionToken() : "req.user in cloud_function_2 is undefined";res.success(response);})
Logs/Trace
test_session started
signing up user 1460659687620
calling cloud_function_1 with session token: r:aa6ca22622c660f139fc2b0e9a249b6d
DATABASE_URI not specified, falling back to localhost.
verbose: Support key pairs Map {}
parse-server-example running on port 1337.
verbose: POST /parse/users { 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.3 (NodeJS 4.3.1)',
accept: '*/*',
'content-type': 'text/plain',
host: 'localhost:1337',
'content-length': '231',
connection: 'close' } {
"username": "1460659687620",
"password": "my pass",
"email": "[email protected]"
}
verbose: {
"status": 201,
"response": {
"objectId": "BWo3njwpYQ",
"createdAt": "2016-04-14T18:48:07.687Z",
"sessionToken": "r:aa6ca22622c660f139fc2b0e9a249b6d"
},
"location": "http://localhost:1337/parse/users/BWo3njwpYQ"
}
verbose: POST /parse/functions/cloud_function_1 { 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.3 (NodeJS 4.3.1)',
accept: '*/*',
'content-type': 'text/plain',
host: 'localhost:1337',
'content-length': '200',
connection: 'close' } {}
cloud_function_1 was called by user: {"ACL":{"BWo3njwpYQ":{"read":true,"write":true},"*":{"read":true}},"username":"1460659687620","email":"[email protected]","updatedAt":"2016-04-14T18:48:07.687Z","createdAt":"2016-04-14T18:48:07.687Z","sessionToken":"r:aa6ca22622c660f139fc2b0e9a249b6d","objectId":"BWo3njwpYQ"}
calling cloud_function_2 from cloud_function_1 using sessionToken: r:aa6ca22622c660f139fc2b0e9a249b6d
verbose: POST /parse/functions/cloud_function_2 { 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.3 (NodeJS 4.3.1)',
accept: '*/*',
'content-type': 'text/plain',
host: 'localhost:1337',
'content-length': '138',
connection: 'close' } {}
cloud_function_2 was called by user: undefined
verbose: {
"response": {
"result": "req.user in cloud_function_2 is undefined"
}
}
verbose: {
"response": {}
}
The text was updated successfully, but these errors were encountered:
Successfully reproduced this in both my env and parse-server-example, so I doubt this is an issue with our own setup. The following setup/reproduction/log are on a newly cloned parse-server-example.
A sessionToken is included when calling
cloud_function_2
fromcloud_function_1
, butreq.user
is still undefined incloud_function_2
.I've previously submitted similar (and I think related) issue #1404, and was advised that I should have revocable session enabled. But this also happens when
cloud_function_1
is called by the iOS client that has it enabled[PFUser enableRevocableSessionInBackground]
.Please note when
cloud_function_2
is directly called by the client,req.user
exists with correct token.Environment Setup
Steps to reproduce
node test_session
with the following:Logs/Trace
The text was updated successfully, but these errors were encountered: