diff --git a/lib/grant-types/authorization-code-grant-type.js b/lib/grant-types/authorization-code-grant-type.js index e487bbe16..10008155f 100644 --- a/lib/grant-types/authorization-code-grant-type.js +++ b/lib/grant-types/authorization-code-grant-type.js @@ -161,19 +161,11 @@ AuthorizationCodeGrantType.prototype.getAuthorizationCode = function(request, cl AuthorizationCodeGrantType.prototype.revokeAuthorizationCode = function(code) { return Promise.try(this.model.revokeAuthorizationCode, code) - .then(function(code) { - if (!code) { + .then(function(status) { + if (!status) { throw new InvalidGrantError('Invalid grant: authorization code is invalid'); } - if (!(code.expiresAt instanceof Date)) { - throw new ServerError('Server error: `expiresAt` must be a Date instance'); - } - - if (code.expiresAt >= new Date()) { - throw new ServerError('Server error: authorization code should be expired'); - } - return code; }); }; diff --git a/lib/grant-types/refresh-token-grant-type.js b/lib/grant-types/refresh-token-grant-type.js index 076dfd234..e176b3fe3 100644 --- a/lib/grant-types/refresh-token-grant-type.js +++ b/lib/grant-types/refresh-token-grant-type.js @@ -123,19 +123,11 @@ RefreshTokenGrantType.prototype.getRefreshToken = function(request, client) { RefreshTokenGrantType.prototype.revokeToken = function(token) { return Promise.try(this.model.revokeToken, token) - .then(function(token) { - if (!token) { + .then(function(status) { + if (!status) { throw new InvalidGrantError('Invalid grant: refresh token is invalid'); } - if (!(token.refreshTokenExpiresAt instanceof Date)) { - throw new ServerError('Server error: `refreshTokenExpiresAt` must be a Date instance'); - } - - if (token.refreshTokenExpiresAt >= new Date()) { - throw new ServerError('Server error: refresh token should be expired'); - } - return token; }); }; diff --git a/test/integration/grant-types/authorization-code-grant-type_test.js b/test/integration/grant-types/authorization-code-grant-type_test.js index 4aff153f8..c3bbb1984 100644 --- a/test/integration/grant-types/authorization-code-grant-type_test.js +++ b/test/integration/grant-types/authorization-code-grant-type_test.js @@ -115,7 +115,7 @@ describe('AuthorizationCodeGrantType integration', function() { var token = {}; var model = { getAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; }, - revokeAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() / 2), user: {} }; }, + revokeAuthorizationCode: function() { return true; }, saveToken: function() { return token; }, validateScope: function() { return 'foo'; } }; @@ -133,7 +133,7 @@ describe('AuthorizationCodeGrantType integration', function() { var client = { id: 'foobar' }; var model = { getAuthorizationCode: function() { return Promise.resolve({ authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }); }, - revokeAuthorizationCode: function() { return Promise.resolve({ authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() / 2), user: {} }); }, + revokeAuthorizationCode: function() { return true; }, saveToken: function() {} }; var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); @@ -146,7 +146,7 @@ describe('AuthorizationCodeGrantType integration', function() { var client = { id: 'foobar' }; var model = { getAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; }, - revokeAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() / 2), user: {} }; }, + revokeAuthorizationCode: function() { return true; }, saveToken: function() {} }; var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); @@ -401,7 +401,7 @@ describe('AuthorizationCodeGrantType integration', function() { var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), redirectUri: 'http://foo.bar', user: {} }; var model = { getAuthorizationCode: function() {}, - revokeAuthorizationCode: function() { return authorizationCode; }, + revokeAuthorizationCode: function() { return true; }, saveToken: function() {} }; var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); @@ -423,7 +423,7 @@ describe('AuthorizationCodeGrantType integration', function() { var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; var model = { getAuthorizationCode: function() {}, - revokeAuthorizationCode: function() { return authorizationCode; }, + revokeAuthorizationCode: function() { return true; }, saveToken: function() {} }; var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); @@ -439,7 +439,7 @@ describe('AuthorizationCodeGrantType integration', function() { var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; var model = { getAuthorizationCode: function() {}, - revokeAuthorizationCode: function() { return Promise.resolve(authorizationCode); }, + revokeAuthorizationCode: function() { return Promise.resolve(true); }, saveToken: function() {} }; var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); diff --git a/test/unit/grant-types/authorization-code-grant-type_test.js b/test/unit/grant-types/authorization-code-grant-type_test.js index 645a79011..61581347d 100644 --- a/test/unit/grant-types/authorization-code-grant-type_test.js +++ b/test/unit/grant-types/authorization-code-grant-type_test.js @@ -40,7 +40,7 @@ describe('AuthorizationCodeGrantType', function() { it('should call `model.revokeAuthorizationCode()`', function() { var model = { getAuthorizationCode: function() {}, - revokeAuthorizationCode: sinon.stub().returns({ authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }), + revokeAuthorizationCode: sinon.stub().returns(true), saveToken: function() {} }; var handler = new AuthorizationCodeGrantType({ accessTokenLifetime: 120, model: model });