aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-28 10:56:09 +0200
committerChocobozzz <me@florianbigard.com>2018-08-28 10:56:09 +0200
commitbfcef50db9c1c1d34ea550ea156c52cb327e160e (patch)
treee3e86ac9d0b2c46d78ba0bcc473a0fc47ef9ce4e /server
parentb224ddd88b767b9a6402e3648993b4f2707057ef (diff)
downloadPeerTube-bfcef50db9c1c1d34ea550ea156c52cb327e160e.tar.gz
PeerTube-bfcef50db9c1c1d34ea550ea156c52cb327e160e.tar.zst
PeerTube-bfcef50db9c1c1d34ea550ea156c52cb327e160e.zip
Fix oauth server module
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/lib/oauth-model.ts6
-rw-r--r--server/models/account/user.ts5
3 files changed, 6 insertions, 7 deletions
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')
14 14
15// --------------------------------------------------------------------------- 15// ---------------------------------------------------------------------------
16 16
17const LAST_MIGRATION_VERSION = 255 17const LAST_MIGRATION_VERSION = 260
18 18
19// --------------------------------------------------------------------------- 19// ---------------------------------------------------------------------------
20 20
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) {
23function getRefreshToken (refreshToken: string) { 23function getRefreshToken (refreshToken: string) {
24 logger.debug('Getting RefreshToken (refreshToken: ' + refreshToken + ').') 24 logger.debug('Getting RefreshToken (refreshToken: ' + refreshToken + ').')
25 25
26
26 return OAuthTokenModel.getByRefreshTokenAndPopulateClient(refreshToken) 27 return OAuthTokenModel.getByRefreshTokenAndPopulateClient(refreshToken)
27} 28}
28 29
@@ -42,7 +43,10 @@ async function getUser (usernameOrEmail: string, password: string) {
42 43
43async function revokeToken (tokenInfo: TokenInfo) { 44async function revokeToken (tokenInfo: TokenInfo) {
44 const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken) 45 const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken)
45 if (token) token.destroy() 46 if (token) {
47 token.destroy()
48 .catch(err => logger.error('Cannot destroy token when revoking token.', { err }))
49 }
46 50
47 /* 51 /*
48 * Thanks to https://github.com/manjeshpv/node-oauth2-server-implementation/blob/master/components/oauth/mongo-models.js 52 * 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<UserModel> {
193 193
194 return UserModel.findAndCountAll(query) 194 return UserModel.findAndCountAll(query)
195 .then(({ rows, count }) => { 195 .then(({ rows, count }) => {
196 console.log(rows[0])
197 console.log(rows[0]['videoQuotaUsed'])
198 console.log(rows[0].get('videoQuotaUsed'))
199 return { 196 return {
200 data: rows, 197 data: rows,
201 total: count 198 total: count
@@ -208,8 +205,6 @@ export class UserModel extends Model<UserModel> {
208 .map(k => parseInt(k, 10) as UserRole) 205 .map(k => parseInt(k, 10) as UserRole)
209 .filter(role => hasUserRight(role, right)) 206 .filter(role => hasUserRight(role, right))
210 207
211 console.log(roles)
212
213 const query = { 208 const query = {
214 attribute: [ 'email' ], 209 attribute: [ 'email' ],
215 where: { 210 where: {