1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Fix oauth server module

This commit is contained in:
Chocobozzz 2018-08-28 10:56:09 +02:00
parent b224ddd88b
commit bfcef50db9
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 11 additions and 24 deletions

View file

@ -23,6 +23,7 @@ function getClient (clientId: string, clientSecret: string) {
function getRefreshToken (refreshToken: string) {
logger.debug('Getting RefreshToken (refreshToken: ' + refreshToken + ').')
return OAuthTokenModel.getByRefreshTokenAndPopulateClient(refreshToken)
}
@ -42,7 +43,10 @@ async function getUser (usernameOrEmail: string, password: string) {
async function revokeToken (tokenInfo: TokenInfo) {
const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken)
if (token) token.destroy()
if (token) {
token.destroy()
.catch(err => logger.error('Cannot destroy token when revoking token.', { err }))
}
/*
* Thanks to https://github.com/manjeshpv/node-oauth2-server-implementation/blob/master/components/oauth/mongo-models.js