diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-28 10:56:09 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-28 10:56:09 +0200 |
commit | bfcef50db9c1c1d34ea550ea156c52cb327e160e (patch) | |
tree | e3e86ac9d0b2c46d78ba0bcc473a0fc47ef9ce4e | |
parent | b224ddd88b767b9a6402e3648993b4f2707057ef (diff) | |
download | PeerTube-bfcef50db9c1c1d34ea550ea156c52cb327e160e.tar.gz PeerTube-bfcef50db9c1c1d34ea550ea156c52cb327e160e.tar.zst PeerTube-bfcef50db9c1c1d34ea550ea156c52cb327e160e.zip |
Fix oauth server module
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | server/initializers/constants.ts | 2 | ||||
-rw-r--r-- | server/lib/oauth-model.ts | 6 | ||||
-rw-r--r-- | server/models/account/user.ts | 5 | ||||
-rw-r--r-- | yarn.lock | 21 |
5 files changed, 11 insertions, 24 deletions
diff --git a/package.json b/package.json index 0455dcb2a..a083cab71 100644 --- a/package.json +++ b/package.json | |||
@@ -113,7 +113,6 @@ | |||
113 | "morgan": "^1.5.3", | 113 | "morgan": "^1.5.3", |
114 | "multer": "^1.1.0", | 114 | "multer": "^1.1.0", |
115 | "nodemailer": "^4.4.2", | 115 | "nodemailer": "^4.4.2", |
116 | "oauth2-server": "^3.0.0", | ||
117 | "parse-torrent": "^6.0.0", | 116 | "parse-torrent": "^6.0.0", |
118 | "password-generator": "^2.0.2", | 117 | "password-generator": "^2.0.2", |
119 | "pem": "^1.12.3", | 118 | "pem": "^1.12.3", |
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 | ||
17 | const LAST_MIGRATION_VERSION = 255 | 17 | const 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) { | |||
23 | function getRefreshToken (refreshToken: string) { | 23 | function 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 | ||
43 | async function revokeToken (tokenInfo: TokenInfo) { | 44 | async 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: { |
@@ -646,7 +646,7 @@ basic-auth@1.1.0: | |||
646 | version "1.1.0" | 646 | version "1.1.0" |
647 | resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-1.1.0.tgz#45221ee429f7ee1e5035be3f51533f1cdfd29884" | 647 | resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-1.1.0.tgz#45221ee429f7ee1e5035be3f51533f1cdfd29884" |
648 | 648 | ||
649 | basic-auth@^2.0.0, basic-auth@~2.0.0: | 649 | basic-auth@~2.0.0: |
650 | version "2.0.0" | 650 | version "2.0.0" |
651 | resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.0.tgz#015db3f353e02e56377755f962742e8981e7bbba" | 651 | resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.0.tgz#015db3f353e02e56377755f962742e8981e7bbba" |
652 | dependencies: | 652 | dependencies: |
@@ -816,7 +816,7 @@ bluebird@^2.10.0: | |||
816 | version "2.11.0" | 816 | version "2.11.0" |
817 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" | 817 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" |
818 | 818 | ||
819 | bluebird@^3.0.5, bluebird@^3.3.4, bluebird@^3.4.6, bluebird@^3.4.7, bluebird@^3.5.0, bluebird@^3.5.1: | 819 | bluebird@^3.0.5, bluebird@^3.3.4, bluebird@^3.4.6, bluebird@^3.4.7, bluebird@^3.5.0: |
820 | version "3.5.1" | 820 | version "3.5.1" |
821 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" | 821 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" |
822 | 822 | ||
@@ -5154,17 +5154,6 @@ oauth2-server@3.0.0: | |||
5154 | statuses "1.3.1" | 5154 | statuses "1.3.1" |
5155 | type-is "1.6.15" | 5155 | type-is "1.6.15" |
5156 | 5156 | ||
5157 | oauth2-server@^3.0.0: | ||
5158 | version "3.0.1" | ||
5159 | resolved "https://registry.yarnpkg.com/oauth2-server/-/oauth2-server-3.0.1.tgz#8fdb7eb78f107832f75c554cb42e59a3f37e41ea" | ||
5160 | dependencies: | ||
5161 | basic-auth "^2.0.0" | ||
5162 | bluebird "^3.5.1" | ||
5163 | lodash "^4.17.10" | ||
5164 | promisify-any "^2.0.1" | ||
5165 | statuses "^1.5.0" | ||
5166 | type-is "^1.6.16" | ||
5167 | |||
5168 | object-assign@4.1.0: | 5157 | object-assign@4.1.0: |
5169 | version "4.1.0" | 5158 | version "4.1.0" |
5170 | resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" | 5159 | resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" |
@@ -5703,7 +5692,7 @@ promise@^7.1.1: | |||
5703 | dependencies: | 5692 | dependencies: |
5704 | asap "~2.0.3" | 5693 | asap "~2.0.3" |
5705 | 5694 | ||
5706 | promisify-any@2.0.1, promisify-any@^2.0.1: | 5695 | promisify-any@2.0.1: |
5707 | version "2.0.1" | 5696 | version "2.0.1" |
5708 | resolved "https://registry.yarnpkg.com/promisify-any/-/promisify-any-2.0.1.tgz#403e00a8813f175242ab50fe33a69f8eece47305" | 5697 | resolved "https://registry.yarnpkg.com/promisify-any/-/promisify-any-2.0.1.tgz#403e00a8813f175242ab50fe33a69f8eece47305" |
5709 | dependencies: | 5698 | dependencies: |
@@ -6849,7 +6838,7 @@ static-extend@^0.1.1: | |||
6849 | define-property "^0.2.5" | 6838 | define-property "^0.2.5" |
6850 | object-copy "^0.1.0" | 6839 | object-copy "^0.1.0" |
6851 | 6840 | ||
6852 | statuses@1, "statuses@>= 1.3.1 < 2", "statuses@>= 1.4.0 < 2", statuses@^1.5.0: | 6841 | statuses@1, "statuses@>= 1.3.1 < 2", "statuses@>= 1.4.0 < 2": |
6853 | version "1.5.0" | 6842 | version "1.5.0" |
6854 | resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" | 6843 | resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" |
6855 | 6844 | ||
@@ -7439,7 +7428,7 @@ type-is@1.6.15: | |||
7439 | media-typer "0.3.0" | 7428 | media-typer "0.3.0" |
7440 | mime-types "~2.1.15" | 7429 | mime-types "~2.1.15" |
7441 | 7430 | ||
7442 | type-is@^1.6.16, type-is@^1.6.4, type-is@~1.6.15, type-is@~1.6.16, type-is@~1.6.6: | 7431 | type-is@^1.6.4, type-is@~1.6.15, type-is@~1.6.16, type-is@~1.6.6: |
7443 | version "1.6.16" | 7432 | version "1.6.16" |
7444 | resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" | 7433 | resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" |
7445 | dependencies: | 7434 | dependencies: |