aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-01 18:16:47 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-01 18:16:47 +0100
commitbf2fc85c834f5be016f119f59844e49fe3751e6a (patch)
tree6e717c10a6037a9829d2ad8e82f4e3cf28b2a3f8
parent2c8a2f7fcc032f36a253af18b47069e80df964c6 (diff)
downloadPeerTube-bf2fc85c834f5be016f119f59844e49fe3751e6a.tar.gz
PeerTube-bf2fc85c834f5be016f119f59844e49fe3751e6a.tar.zst
PeerTube-bf2fc85c834f5be016f119f59844e49fe3751e6a.zip
Server: fix refreshing token that fails
-rw-r--r--server/lib/oauth-model.js3
-rw-r--r--server/models/oauth-token.js6
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) {
60} 60}
61 61
62function revokeToken (token) { 62function revokeToken (token) {
63 return OAuthToken.getByRefreshToken(token.refreshToken).then(function (tokenDB) { 63 return OAuthToken.getByRefreshTokenAndPopulateUser(token.refreshToken).then(function (tokenDB) {
64 if (tokenDB) tokenDB.remove() 64 if (tokenDB) tokenDB.remove()
65 65
66 /* 66 /*
@@ -72,6 +72,7 @@ function revokeToken (token) {
72 */ 72 */
73 const expiredToken = tokenDB 73 const expiredToken = tokenDB
74 expiredToken.refreshTokenExpiresAt = new Date('2015-05-28T06:59:53.000Z') 74 expiredToken.refreshTokenExpiresAt = new Date('2015-05-28T06:59:53.000Z')
75
75 return expiredToken 76 return expiredToken
76 }) 77 })
77} 78}
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)
20OAuthTokenSchema.statics = { 20OAuthTokenSchema.statics = {
21 getByRefreshTokenAndPopulateClient, 21 getByRefreshTokenAndPopulateClient,
22 getByTokenAndPopulateUser, 22 getByTokenAndPopulateUser,
23 getByRefreshToken, 23 getByRefreshTokenAndPopulateUser,
24 removeByUserId 24 removeByUserId
25} 25}
26 26
@@ -51,8 +51,8 @@ function getByTokenAndPopulateUser (bearerToken) {
51 return this.findOne({ accessToken: bearerToken }).populate('user').exec() 51 return this.findOne({ accessToken: bearerToken }).populate('user').exec()
52} 52}
53 53
54function getByRefreshToken (refreshToken) { 54function getByRefreshTokenAndPopulateUser (refreshToken) {
55 return this.findOne({ refreshToken: refreshToken }).exec() 55 return this.findOne({ refreshToken: refreshToken }).populate('user').exec()
56} 56}
57 57
58function removeByUserId (userId, callback) { 58function removeByUserId (userId, callback) {