Last active
December 5, 2017 02:48
-
-
Save pulkitsinghal/0c5bf6bbab495187dbf7 to your computer and use it in GitHub Desktop.
Validate X-Parse-Session-Token in NodeJS before calling background jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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