Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

check error results from fetchAuthorizationInformation() #105

Merged
merged 2 commits into from

2 participants

@evanp

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
@evanp 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
@evanp 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
@ciaranj ciaranj merged commit ec9dcad into ciaranj:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 28, 2012
  1. @evanp

    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. @evanp

    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.
View
10 lib/auth.strategies/oauth/_oauthservices.js
@@ -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);
+ }
});
}
View
9 lib/auth.strategies/oauth/oauth.js
@@ -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.