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

update errors messages #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/exchange/authorizationCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = function(options, issue) {
var userProperty = options.userProperty || 'user';

return function authorization_code(req, res, next) {
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?')); }
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget body-parser middleware ?')); }

// The 'user' property of `req` holds the authenticated user. In the case
// of the token endpoint, the property will contain the OAuth 2.0 client.
Expand Down
2 changes: 1 addition & 1 deletion lib/exchange/clientCredentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = function(options, issue) {
}

return function client_credentials(req, res, next) {
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?')); }
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget body-parser middleware ?')); }

// The 'user' property of `req` holds the authenticated user. In the case
// of the token endpoint, the property will contain the OAuth 2.0 client.
Expand Down
2 changes: 1 addition & 1 deletion lib/exchange/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = function(options, issue) {
}

return function password(req, res, next) {
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?')); }
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget body-parser middleware ?')); }

// The 'user' property of `req` holds the authenticated user. In the case
// of the token endpoint, the property will contain the OAuth 2.0 client.
Expand Down
2 changes: 1 addition & 1 deletion lib/exchange/refreshToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = function(options, issue) {
}

return function refresh_token(req, res, next) {
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?')); }
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget body-parser middleware ?')); }

// The 'user' property of `req` holds the authenticated user. In the case
// of the token endpoint, the property will contain the OAuth 2.0 client.
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware/authorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module.exports = function(server, options, validate, immediate) {
, key = options.sessionKey || 'authorize';

return function authorization(req, res, next) {
if (!req.session) { return next(new Error('OAuth2orize requires session support. Did you forget app.use(express.session(...))?')); }
if (!req.session) { return next(new Error('OAuth2orize requires session support. Did you forget session middleware ?')); }

var body = req.body || {}
, type = req.query.response_type || body.response_type;
Expand Down
4 changes: 2 additions & 2 deletions lib/middleware/decision.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ module.exports = function(server, options, parse) {
, key = options.sessionKey || 'authorize';

return function decision(req, res, next) {
if (!req.session) { return next(new Error('OAuth2orize requires session support. Did you forget app.use(express.session(...))?')); }
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?')); }
if (!req.session) { return next(new Error('OAuth2orize requires session support. Did you forget session middleware ?')); }
if (!req.body) { return next(new Error('OAuth2orize requires body parsing. Did you forget body-parser middleware ?')); }
if (!req.oauth2) { return next(new Error('OAuth2orize requires transaction support. Did you forget oauth2orize.transactionLoader(...)?')); }
if (!req.session[key]) { return next(new ForbiddenError('Unable to load OAuth 2.0 transactions from session')); }

Expand Down
2 changes: 1 addition & 1 deletion lib/middleware/transactionLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = function(server, options) {
, key = options.sessionKey || 'authorize';

return function transactionLoader(req, res, next) {
if (!req.session) { return next(new Error('OAuth2orize requires session support. Did you forget app.use(express.session(...))?')); }
if (!req.session) { return next(new Error('OAuth2orize requires session support. Did you forget session middleware ?')); }
if (!req.session[key]) { return next(new ForbiddenError('Unable to load OAuth 2.0 transactions from session')); }

var query = req.query || {}
Expand Down
2 changes: 1 addition & 1 deletion test/exchange/authorizationCode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ describe('exchange.authorizationCode', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?');
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget body-parser middleware ?');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/exchange/clientCredentials.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe('exchange.clientCredentials', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?');
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget body-parser middleware ?');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/exchange/password.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ describe('exchange.password', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?');
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget body-parser middleware ?');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/exchange/refreshToken.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ describe('exchange.refreshToken', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?');
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget body-parser middleware ?');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/middleware/authorization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ describe('authorization', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.message).to.equal('OAuth2orize requires session support. Did you forget app.use(express.session(...))?');
expect(err.message).to.equal('OAuth2orize requires session support. Did you forget session middleware ?');
});

it('should not start transaction', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/middleware/decision.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describe('decision', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.message).to.equal('OAuth2orize requires session support. Did you forget app.use(express.session(...))?');
expect(err.message).to.equal('OAuth2orize requires session support. Did you forget session middleware ?');
});

it('should not set user on transaction', function() {
Expand Down Expand Up @@ -297,7 +297,7 @@ describe('decision', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget app.use(express.bodyParser())?');
expect(err.message).to.equal('OAuth2orize requires body parsing. Did you forget body-parser middleware ?');
});

it('should not set user on transaction', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/middleware/transactionLoader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ describe('transactionLoader', function() {

it('should error', function() {
expect(err).to.be.an.instanceOf(Error);
expect(err.message).to.equal('OAuth2orize requires session support. Did you forget app.use(express.session(...))?');
expect(err.message).to.equal('OAuth2orize requires session support. Did you forget session middleware ?');
});

it('should not restore transaction', function() {
Expand Down