node-oauth2-server
Advanced tools
Comparing version 1.5.2-invalid-token to 1.5.3-invalid-token
@@ -34,5 +34,7 @@ /** | ||
case 'invalid_request': | ||
case 'invalid_token': | ||
this.code = 400; | ||
break; | ||
case 'invalid_token': | ||
this.code = 401; | ||
break; | ||
case 'server_error': | ||
@@ -39,0 +41,0 @@ this.code = 503; |
@@ -96,3 +96,3 @@ /** | ||
req.oauth = { internal: false }; | ||
oauth.now = new Date; | ||
oauth.now = new Date(); | ||
@@ -134,2 +134,2 @@ if (req.path === '/oauth/token') { | ||
}; | ||
}; | ||
}; |
{ | ||
"name": "node-oauth2-server", | ||
"description": "Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in node.js", | ||
"version": "1.5.2-invalid-token", | ||
"version": "1.5.3-invalid-token", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "oauth", |
24
test.js
@@ -29,6 +29,24 @@ var express = require('express'), | ||
app.post('/oauth/authorise', app.oauth.codeGrant(function (req) { | ||
return req.body.auth === 'yes'; | ||
})); | ||
app.post('/oauth/authorise', function (req, res, next) { | ||
if (!req.session.user) { | ||
return res.redirect('/login?client_id=' + req.query.client_id + | ||
'&redirect_uri=' + req.query.redirect_uri); | ||
} | ||
next(); | ||
}, app.oauth.codeGrant); | ||
app.post('/oauth/authorise', function (req, res, next) { | ||
if (!req.session.user) { | ||
return res.redirect('/login?client_id=' + req.query.client_id + | ||
'&redirect_uri=' + req.query.redirect_uri); | ||
} | ||
next(); | ||
}, app.oauth.codeGrant(function (req, next) { | ||
next(null, req.body.allow === 'yes', req.session.user.id, req.session.user); | ||
}), function (err, req, res, next) { | ||
res.render('authoriseError'); | ||
}); | ||
app.get('/login', function (req, res, next) { | ||
@@ -35,0 +53,0 @@ res.render('login', { |
@@ -63,3 +63,3 @@ /** | ||
.set('Authorization', 'Bearer thom') | ||
.expect(400, /the access token provided is invalid/i, done); | ||
.expect(401, /the access token provided is invalid/i, done); | ||
}); | ||
@@ -93,3 +93,3 @@ | ||
.send({ access_token: 'thom' }) | ||
.expect(400, /the access token provided is invalid/i, done); | ||
.expect(401, /the access token provided is invalid/i, done); | ||
}); | ||
@@ -111,3 +111,3 @@ | ||
.get('/?access_token=thom') | ||
.expect(400, /the access token provided is invalid/i, done); | ||
.expect(401, /the access token provided is invalid/i, done); | ||
}); | ||
@@ -141,3 +141,3 @@ | ||
.get('/?access_token=thom') | ||
.expect(400, /the access token provided is invalid/i, done); | ||
.expect(401, /the access token provided is invalid/i, done); | ||
}); | ||
@@ -156,3 +156,3 @@ | ||
.get('/?access_token=thom') | ||
.expect(400, /the access token provided has expired/i, done); | ||
.expect(401, /the access token provided has expired/i, done); | ||
}); | ||
@@ -159,0 +159,0 @@ |
85382
1817