Created
August 11, 2016 10:24
-
-
Save stephenwil/bc3649ddbb3a8f5461bcc458a562411f to your computer and use it in GitHub Desktop.
Loopback : promise and the access token model
This file contains hidden or 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
/** | |
* 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