From bf2fc85c834f5be016f119f59844e49fe3751e6a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 1 Nov 2016 18:16:47 +0100 Subject: [PATCH] Server: fix refreshing token that fails --- server/lib/oauth-model.js | 3 ++- server/models/oauth-token.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/lib/oauth-model.js b/server/lib/oauth-model.js index 45f796796..922ef0b1f 100644 --- a/server/lib/oauth-model.js +++ b/server/lib/oauth-model.js @@ -60,7 +60,7 @@ function getUser (username, password) { } function revokeToken (token) { - return OAuthToken.getByRefreshToken(token.refreshToken).then(function (tokenDB) { + return OAuthToken.getByRefreshTokenAndPopulateUser(token.refreshToken).then(function (tokenDB) { if (tokenDB) tokenDB.remove() /* @@ -72,6 +72,7 @@ function revokeToken (token) { */ const expiredToken = tokenDB expiredToken.refreshTokenExpiresAt = new Date('2015-05-28T06:59:53.000Z') + return expiredToken }) } diff --git a/server/models/oauth-token.js b/server/models/oauth-token.js index 5beb47bed..04fb9540d 100644 --- a/server/models/oauth-token.js +++ b/server/models/oauth-token.js @@ -20,7 +20,7 @@ OAuthTokenSchema.path('user').required(true) OAuthTokenSchema.statics = { getByRefreshTokenAndPopulateClient, getByTokenAndPopulateUser, - getByRefreshToken, + getByRefreshTokenAndPopulateUser, removeByUserId } @@ -51,8 +51,8 @@ function getByTokenAndPopulateUser (bearerToken) { return this.findOne({ accessToken: bearerToken }).populate('user').exec() } -function getByRefreshToken (refreshToken) { - return this.findOne({ refreshToken: refreshToken }).exec() +function getByRefreshTokenAndPopulateUser (refreshToken) { + return this.findOne({ refreshToken: refreshToken }).populate('user').exec() } function removeByUserId (userId, callback) { -- 2.25.1