node-oauth2-server
Advanced tools
Comparing version 1.5.2-invalid-token to 1.5.2
@@ -62,3 +62,3 @@ /** | ||
if (!token) { | ||
return next(error('invalid_token', 'The access token provided is invalid.')); | ||
return next(error('invalid_grant', 'The access token provided is invalid.')); | ||
} | ||
@@ -68,3 +68,3 @@ | ||
if (token.expires !== null && (!token.expires || token.expires < this.now)) { | ||
return next(error('invalid_token', 'The access token provided has expired.')); | ||
return next(error('invalid_grant', 'The access token provided has expired.')); | ||
} | ||
@@ -71,0 +71,0 @@ |
@@ -34,3 +34,2 @@ /** | ||
case 'invalid_request': | ||
case 'invalid_token': | ||
this.code = 400; | ||
@@ -37,0 +36,0 @@ break; |
{ | ||
"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.2", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "oauth", |
@@ -52,3 +52,3 @@ # Node OAuth2 Server [![Build Status](https://travis-ci.org/nightworld/node-oauth2-server.png?branch=master)](https://travis-ci.org/nightworld/node-oauth2-server) | ||
- Does not yet support authorization code grant type | ||
- Does not yet support authorization code grant type (NOTE: this has landed in the [https://github.com/nightworld/node-oauth2-server/tree/2.0](2.0 branch) (still unstable)) | ||
@@ -55,0 +55,0 @@ ## Options |
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', { |
@@ -111,9 +111,5 @@ /** | ||
getClient: function (id, secret, callback) { | ||
try { | ||
id.should.equal('thom'); | ||
secret.should.equal('nightworld'); | ||
callback(false, false); | ||
} catch (e) { | ||
return done(e); | ||
} | ||
id.should.equal('thom'); | ||
secret.should.equal('nightworld'); | ||
callback(false, false); | ||
} | ||
@@ -135,9 +131,5 @@ }, | ||
getClient: function (id, secret, callback) { | ||
try { | ||
id.should.equal('thom'); | ||
secret.should.equal('nightworld'); | ||
callback(false, false); | ||
} catch (e) { | ||
return done(e); | ||
} | ||
id.should.equal('thom'); | ||
secret.should.equal('nightworld'); | ||
callback(false, false); | ||
} | ||
@@ -601,8 +593,4 @@ }, | ||
saveAccessToken: function (accessToken, clientId, userId, expires, callback) { | ||
try { | ||
accessToken.should.equal('thommy'); | ||
callback(); | ||
} catch (e) { | ||
return callback(e); | ||
} | ||
accessToken.should.equal('thommy'); | ||
callback(); | ||
} | ||
@@ -666,12 +654,10 @@ }, | ||
saveAccessToken: function (accessToken, clientId, userId, expires, callback) { | ||
try { | ||
accessToken.should.be.a('string'); | ||
accessToken.should.have.length(40); | ||
clientId.should.equal('thom'); | ||
userId.should.equal(1); | ||
(+expires).should.be.within(10, (+new Date()) + 3600000); | ||
callback(); | ||
} catch (e) { | ||
return callback(e); | ||
} | ||
accessToken.should.be.a('string'); | ||
accessToken.should.have.length(40); | ||
clientId.should.equal('thom'); | ||
userId.should.equal(1); | ||
var d = new Date; | ||
d.setSeconds(d.getSeconds() + 3600); | ||
(+expires).should.be.approximately(+d, 1); | ||
callback(); | ||
} | ||
@@ -706,12 +692,10 @@ }, | ||
saveRefreshToken: function (refreshToken, clientId, userId, expires, callback) { | ||
try { | ||
refreshToken.should.be.a('string'); | ||
refreshToken.should.have.length(40); | ||
clientId.should.equal('thom'); | ||
userId.should.equal(1); | ||
(+expires).should.be.within(10, (+new Date()) + 1209600000); | ||
callback(); | ||
} catch (e) { | ||
return callback(e); | ||
} | ||
refreshToken.should.be.a('string'); | ||
refreshToken.should.have.length(40); | ||
clientId.should.equal('thom'); | ||
userId.should.equal(1); | ||
var d = new Date; | ||
d.setSeconds(d.getSeconds() + 1209600); | ||
(+expires).should.be.approximately(+d, 1); | ||
callback(); | ||
} | ||
@@ -718,0 +702,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
85182
1
1797