Permalink
Browse files

Merge pull request #106 from evanp/CheckGenerateAccessTokenErr

Check the err return from generateAccessToken()
  • Loading branch information...
2 parents ec9dcad + f9de1c6 commit b2dcc61b4abb8436dad46b1888fa7e67dfa397a8 @ciaranj committed Jun 19, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/auth.strategies/oauth/_oauthservices.js
@@ -153,8 +153,13 @@ exports.OAuthServices.prototype.accessToken= function(request, protocol, callbac
// Check if the signature is correct and return a access token
if(calculatedSignature == oauth_signature /*|| self.calculateSignatureGoogleWay(method, protocol, url, path, requestParameters, tokenObject.token_secret, user.secret) == requestParameters.oauth_signature */) {
self.provider.generateAccessToken(requestParameters['oauth_token'], function(err, result) {
- if(result.access_token == null || result.token_secret == null) { callback(new errors.OAuthProviderError("generateAccessToken must return a object with fields [access_token, token_secret]"), null); return; }
- callback(null, result);
+ if(err) {
+ callback(new errors.OAuthUnauthorizedError('Invalid / expired Token'), null);
+ } else if(result.access_token == null || result.token_secret == null) {
+ callback(new errors.OAuthProviderError("generateAccessToken must return a object with fields [access_token, token_secret]"), null);
+ } else {
+ callback(null, result);
+ }
});
} else {
callback(new errors.OAuthUnauthorizedError("Invalid signature"), null);

0 comments on commit b2dcc61

Please sign in to comment.