Skip to content

Instantly share code, notes, and snippets.

@stephenwil
Created August 11, 2016 10:24
Show Gist options
  • Save stephenwil/bc3649ddbb3a8f5461bcc458a562411f to your computer and use it in GitHub Desktop.
Save stephenwil/bc3649ddbb3a8f5461bcc458a562411f to your computer and use it in GitHub Desktop.
Loopback : promise and the access token model
/**
* The Access Token model in loopback doesn't support Promises out-the-box, and it won't work with Bluebird Promisify
*/
util.tokenValidateAsync = function(token) {
return new Promise(function(resolve, reject) {
token.validate(function(err, isValid){
if (!err) {
resolve(isValid);
}
else {
reject(err);
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment