Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check error results from fetchAuthorizationInformation() #105

Merged
merged 2 commits into from May 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/auth.strategies/oauth/_oauthservices.js
Expand Up @@ -298,9 +298,13 @@ exports.OAuthServices.prototype.authorize= function(request, protocol, callback)
**/ **/
exports.OAuthServices.prototype.fetchAuthorizationInformation = function(username, token, callback) { exports.OAuthServices.prototype.fetchAuthorizationInformation = function(username, token, callback) {
this.provider.fetchAuthorizationInformation(username, token, function(err, application, user) { 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;} if(err) {
// Return the value to calling plugin callback(new errors.OAuthProviderError('Invalid Username/Token'), null, null);
callback(err, application, user); } 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);
}
}); });
} }


Expand Down
9 changes: 7 additions & 2 deletions lib/auth.strategies/oauth/oauth.js
Expand Up @@ -128,8 +128,13 @@ module.exports= function(options) {
} else { } else {
// Fetch the needed data // Fetch the needed data
my['oauth_service'].fetchAuthorizationInformation(req.body['username'], result.token, function(err, application, user) { my['oauth_service'].fetchAuthorizationInformation(req.body['username'], result.token, function(err, application, user) {
// Signal callback about finish authorization if(err) {
my.authorize_provider.call(self, null, req, res, true, result, application, user); // 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);
}
}); });
} }
}); });
Expand Down