Skip to content
Merged
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/grant-types/refresh-token-grant-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ RefreshTokenGrantType.prototype.getRefreshToken = function(request, client) {
throw new ServerError('Server error: `getRefreshToken()` did not return a `user` object');
}

if (token.client.id !== client.id) {
if (token.client.id !== client.clientId) {
throw new InvalidGrantError('Invalid grant: refresh token is invalid');
}

Expand Down
24 changes: 12 additions & 12 deletions test/integration/grant-types/refresh-token-grant-type_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should return a token', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var token = { accessToken: 'foo', client: { id: 123 }, user: {} };
var model = {
getRefreshToken: function() { return token; },
Expand All @@ -130,7 +130,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should support promises', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var model = {
getRefreshToken: function() { return Promise.resolve({ accessToken: 'foo', client: { id: 123 }, user: {} }); },
revokeToken: function() { return Promise.resolve({ accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }); },
Expand All @@ -143,7 +143,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should support non-promises', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var model = {
getRefreshToken: function() { return { accessToken: 'foo', client: { id: 123 }, user: {} }; },
revokeToken: function() { return { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; },
Expand All @@ -156,7 +156,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should support callbacks', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var model = {
getRefreshToken: function(refreshToken, callback) { callback(null, { accessToken: 'foo', client: { id: 123 }, user: {} }); },
revokeToken: function(refreshToken, callback) { callback(null, { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }); },
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should throw an error if `refreshToken` is not found', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var model = {
getRefreshToken: function() { return; },
revokeToken: function() {},
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should throw an error if the client id does not match', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var model = {
getRefreshToken: function() {
return { accessToken: 'foo', client: { id: 456 }, user: {} };
Expand Down Expand Up @@ -309,7 +309,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should throw an error if `refresh_token` is expired', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var date = new Date(new Date() / 2);
var model = {
getRefreshToken: function() {
Expand All @@ -330,7 +330,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should throw an error if `refreshTokenExpiresAt` is not a date value', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var model = {
getRefreshToken: function() {
return { accessToken: 'foo', client: { id: 123 }, refreshTokenExpiresAt: 'stringvalue', user: {} };
Expand All @@ -350,7 +350,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should return a token', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var token = { accessToken: 'foo', client: { id: 123 }, user: {} };
var model = {
getRefreshToken: function() { return token; },
Expand All @@ -368,7 +368,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should support promises', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var token = { accessToken: 'foo', client: { id: 123 }, user: {} };
var model = {
getRefreshToken: function() { return Promise.resolve(token); },
Expand All @@ -382,7 +382,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should support non-promises', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var token = { accessToken: 'foo', client: { id: 123 }, user: {} };
var model = {
getRefreshToken: function() { return token; },
Expand All @@ -396,7 +396,7 @@ describe('RefreshTokenGrantType integration', function() {
});

it('should support callbacks', function() {
var client = { id: 123 };
var client = { clientId: 123 };
var token = { accessToken: 'foo', client: { id: 123 }, user: {} };
var model = {
getRefreshToken: function(refreshToken, callback) { callback(null, token); },
Expand Down