From bfcef50db9c1c1d34ea550ea156c52cb327e160e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 28 Aug 2018 10:56:09 +0200 Subject: Fix oauth server module --- server/lib/oauth-model.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'server/lib') diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts index f159ad6a9..272e90f3a 100644 --- a/server/lib/oauth-model.ts +++ b/server/lib/oauth-model.ts @@ -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 -- cgit v1.2.3