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/initializers/constants.ts | 2 +- server/lib/oauth-model.ts | 6 +++++- server/models/account/user.ts | 5 ----- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'server') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 4111d04ec..7f1b25654 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -14,7 +14,7 @@ let config: IConfig = require('config') // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 255 +const LAST_MIGRATION_VERSION = 260 // --------------------------------------------------------------------------- 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 diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 178012eae..a88ec244f 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -193,9 +193,6 @@ export class UserModel extends Model { return UserModel.findAndCountAll(query) .then(({ rows, count }) => { - console.log(rows[0]) - console.log(rows[0]['videoQuotaUsed']) - console.log(rows[0].get('videoQuotaUsed')) return { data: rows, total: count @@ -208,8 +205,6 @@ export class UserModel extends Model { .map(k => parseInt(k, 10) as UserRole) .filter(role => hasUserRight(role, right)) - console.log(roles) - const query = { attribute: [ 'email' ], where: { -- cgit v1.2.3