Skip to content

Commit

Permalink
Merge pull request #28 from siacomuzzi/invalid_redirect_uri_error
Browse files Browse the repository at this point in the history
return AuthorizationError (instead of Error) when redirect_uri was not specified
  • Loading branch information
jaredhanson committed Feb 15, 2017
2 parents a39f28a + ab1acbe commit 763cca9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/response/fragment.js
@@ -1,5 +1,6 @@
var url = require('url')
, qs = require('querystring');
, qs = require('querystring')
, AuthorizationError = require('oauth2orize').AuthorizationError;

/**
* Authorization Response parameters are encoded in the fragment added to the redirect_uri when
Expand All @@ -15,5 +16,5 @@ exports = module.exports = function (txn, res, params) {


exports.validate = function(txn) {
if (!txn.redirectURI) { throw new Error('Unable to issue redirect for OAuth 2.0 transaction'); }
if (!txn.redirectURI) { throw new AuthorizationError('Unable to issue redirect for OAuth 2.0 transaction', 'server_error'); }
};
2 changes: 2 additions & 0 deletions test/grant/codeIdToken.test.js
Expand Up @@ -671,6 +671,8 @@ describe('grant.codeIdToken', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.constructor.name).to.equal('AuthorizationError');
expect(err.code).to.equal('server_error');
expect(err.message).to.equal('Unable to issue redirect for OAuth 2.0 transaction');
});
});
Expand Down
2 changes: 2 additions & 0 deletions test/grant/idToken.test.js
Expand Up @@ -679,6 +679,8 @@ describe('grant.idToken', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.constructor.name).to.equal('AuthorizationError');
expect(err.code).to.equal('server_error');
expect(err.message).to.equal('Unable to issue redirect for OAuth 2.0 transaction');
});
});
Expand Down
2 changes: 2 additions & 0 deletions test/grant/idTokenToken.test.js
Expand Up @@ -921,6 +921,8 @@ describe('grant.idTokenToken', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.constructor.name).to.equal('AuthorizationError');
expect(err.code).to.equal('server_error');
expect(err.message).to.equal('Unable to issue redirect for OAuth 2.0 transaction');
});
});
Expand Down

0 comments on commit 763cca9

Please sign in to comment.