Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

check error results from fetchAuthorizationInformation() #105

Merged
merged 2 commits into from

2 participants

Evan Prodromou Ciaran Jessup
Evan Prodromou

The code wasn't checking error results from fetchAuthorizationInformation(). It does now, and delegates to the authorization_provider to display them.

evanp added some commits
Evan Prodromou evanp authorizeUrlMethod() checks err returned from fetchAuthorizationInfor…
…mation()

We weren't checking the err response before. This patch adds a quick check and a call to the authorize_provider if there's an error.
5a73712
Evan Prodromou evanp Also check intermediate error for fetchAuthorizationInformation()
We were also skipping over the intermediate error from the provider's
fetchAuthorizationInformation(), which will cause an (incorrect) error
about the provider interface.
0c2f749
Ciaran Jessup ciaranj merged commit ec9dcad into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 28, 2012
  1. Evan Prodromou

    authorizeUrlMethod() checks err returned from fetchAuthorizationInfor…

    evanp authored
    …mation()
    
    We weren't checking the err response before. This patch adds a quick check and a call to the authorize_provider if there's an error.
  2. Evan Prodromou

    Also check intermediate error for fetchAuthorizationInformation()

    evanp authored
    We were also skipping over the intermediate error from the provider's
    fetchAuthorizationInformation(), which will cause an (incorrect) error
    about the provider interface.
This page is out of date. Refresh to see the latest.
10 lib/auth.strategies/oauth/_oauthservices.js
View
@@ -298,9 +298,13 @@ exports.OAuthServices.prototype.authorize= function(request, protocol, callback)
**/
exports.OAuthServices.prototype.fetchAuthorizationInformation = function(username, token, callback) {
this.provider.fetchAuthorizationInformation(username, token, function(err, application, user) {
- if(application.title == null || application.description == null || user.token == null || user.username == null) { callback(new errors.OAuthProviderError("provider: applicationByConsumerKey must return a application object with fields [title, description] and a user object with fields [username, token]"), null); return;}
- // Return the value to calling plugin
- callback(err, application, user);
+ if(err) {
+ callback(new errors.OAuthProviderError('Invalid Username/Token'), null, null);
+ } else if(application.title == null || application.description == null || user.token == null || user.username == null) { callback(new errors.OAuthProviderError("provider: fetchAuthorizationInformation must return a application object with fields [title, description] and a user object with fields [username, token]"), null, null); return;
+ } else {
+ // Return the value to calling plugin
+ callback(err, application, user);
+ }
});
}
9 lib/auth.strategies/oauth/oauth.js
View
@@ -128,8 +128,13 @@ module.exports= function(options) {
} else {
// Fetch the needed data
my['oauth_service'].fetchAuthorizationInformation(req.body['username'], result.token, function(err, application, user) {
- // Signal callback about finish authorization
- my.authorize_provider.call(self, null, req, res, true, result, application, user);
+ if(err) {
+ // Delegate to the function of the user
+ my.authorize_provider.call(self, err, req, res, false, {token:req.body['oauth_token']});
+ } else {
+ // Signal callback about finish authorization
+ my.authorize_provider.call(self, null, req, res, true, result, application, user);
+ }
});
}
});
Something went wrong with that request. Please try again.