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

Fix for error handling when using more than one 2-legged OAuth strategy #114

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/auth.strategies/oauth/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module.exports= function(options) {
that.name= options.name || "oauth";
var my= {};
var legs = null;

// Ensure we have default values and legal options
my['request_token_url']= options['request_token_url'] || '/oauth/request_token';
my['authorize_url']= options['authorize_url'] || '/oauth/authorize';
Expand Down Expand Up @@ -72,10 +71,11 @@ module.exports= function(options) {
var self= this;
my['oauth_service'].authorize(req, my['oauth_protocol'], function(error, result) {
if( error ) {
res.writeHead(error.statusCode, {'Content-Type': 'text/plain',
'WWW-Authenticate': 'OAuth realm="'+my.realm+'"'})
res.end(error.message);
self.fail(callback);
// Create errors object if it doesn't exist
req.getAuthDetails()['errors'] || ( req.getAuthDetails()['errors'] = {} );
// Store error with strategy key as name
req.getAuthDetails()['errors'][that.name] = error;
self.fail(callback);
}
else {
self.success(result, callback);
Expand Down