Server: fix refreshing token that fails
This commit is contained in:
parent
2c8a2f7fcc
commit
bf2fc85c83
|
@ -60,7 +60,7 @@ function getUser (username, password) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function revokeToken (token) {
|
function revokeToken (token) {
|
||||||
return OAuthToken.getByRefreshToken(token.refreshToken).then(function (tokenDB) {
|
return OAuthToken.getByRefreshTokenAndPopulateUser(token.refreshToken).then(function (tokenDB) {
|
||||||
if (tokenDB) tokenDB.remove()
|
if (tokenDB) tokenDB.remove()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -72,6 +72,7 @@ function revokeToken (token) {
|
||||||
*/
|
*/
|
||||||
const expiredToken = tokenDB
|
const expiredToken = tokenDB
|
||||||
expiredToken.refreshTokenExpiresAt = new Date('2015-05-28T06:59:53.000Z')
|
expiredToken.refreshTokenExpiresAt = new Date('2015-05-28T06:59:53.000Z')
|
||||||
|
|
||||||
return expiredToken
|
return expiredToken
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ OAuthTokenSchema.path('user').required(true)
|
||||||
OAuthTokenSchema.statics = {
|
OAuthTokenSchema.statics = {
|
||||||
getByRefreshTokenAndPopulateClient,
|
getByRefreshTokenAndPopulateClient,
|
||||||
getByTokenAndPopulateUser,
|
getByTokenAndPopulateUser,
|
||||||
getByRefreshToken,
|
getByRefreshTokenAndPopulateUser,
|
||||||
removeByUserId
|
removeByUserId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ function getByTokenAndPopulateUser (bearerToken) {
|
||||||
return this.findOne({ accessToken: bearerToken }).populate('user').exec()
|
return this.findOne({ accessToken: bearerToken }).populate('user').exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getByRefreshToken (refreshToken) {
|
function getByRefreshTokenAndPopulateUser (refreshToken) {
|
||||||
return this.findOne({ refreshToken: refreshToken }).exec()
|
return this.findOne({ refreshToken: refreshToken }).populate('user').exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeByUserId (userId, callback) {
|
function removeByUserId (userId, callback) {
|
||||||
|
|
Loading…
Reference in New Issue