Skip to content

Instantly share code, notes, and snippets.

@pulkitsinghal
Last active December 5, 2017 02:48
Show Gist options
  • Save pulkitsinghal/0c5bf6bbab495187dbf7 to your computer and use it in GitHub Desktop.
Save pulkitsinghal/0c5bf6bbab495187dbf7 to your computer and use it in GitHub Desktop.
Validate X-Parse-Session-Token in NodeJS before calling background jobs
var deferred = q.defer();
request.get({
url: 'https://api.parse.com/1/users/me', // validate session token
headers: {
'X-Parse-Session-Token': req.header('X-Parse-Session-Token'),
'X-Parse-Application-Id': 'secret',
'X-Parse-REST-API-Key': 'secret'
}
},
function(err, resp, body){
// etc.
});
return deferred.promise
.then(function(response){
// WARNING: At this point, we know its a valid user but that's ALL we know,
// we do NOT know if it has sufficient permissions to run the job.
// TODO: call background job with master key
},
function(error){
// etc.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment