Fix oauth server module
authorChocobozzz <me@florianbigard.com>
Tue, 28 Aug 2018 08:56:09 +0000 (10:56 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 28 Aug 2018 08:56:09 +0000 (10:56 +0200)
package.json
server/initializers/constants.ts
server/lib/oauth-model.ts
server/models/account/user.ts
yarn.lock

index 0455dcb2ae2fe56b0284594b74eed8eb75aa0447..a083cab7189dd1d1f01cf90178b73f6047305520 100644 (file)
     "morgan": "^1.5.3",
     "multer": "^1.1.0",
     "nodemailer": "^4.4.2",
-    "oauth2-server": "^3.0.0",
     "parse-torrent": "^6.0.0",
     "password-generator": "^2.0.2",
     "pem": "^1.12.3",
index 4111d04ecff1c7fc1c193ecd1b1dd786a89fee86..7f1b25654cc072879986530bb86847875361ce31 100644 (file)
@@ -14,7 +14,7 @@ let config: IConfig = require('config')
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 255
+const LAST_MIGRATION_VERSION = 260
 
 // ---------------------------------------------------------------------------
 
index f159ad6a90c4b8d7bd2a47880a346124df8d4d0b..272e90f3a4b7305ac32a97d17bd07599629ea52e 100644 (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
index 178012eaea4c7f4af57ff04271a06d6dbfb0099f..a88ec244fce736ed89d692e1795f622cb8c98939 100644 (file)
@@ -193,9 +193,6 @@ export class UserModel extends Model<UserModel> {
 
     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<UserModel> {
       .map(k => parseInt(k, 10) as UserRole)
       .filter(role => hasUserRight(role, right))
 
-    console.log(roles)
-
     const query = {
       attribute: [ 'email' ],
       where: {
index 43d97c1277a5ed50212b902dd9ba0b83e413e1e0..93ffe3619e969e1dc8412814421eb2fd3dfef33c 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -646,7 +646,7 @@ basic-auth@1.1.0:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-1.1.0.tgz#45221ee429f7ee1e5035be3f51533f1cdfd29884"
 
-basic-auth@^2.0.0, basic-auth@~2.0.0:
+basic-auth@~2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.0.tgz#015db3f353e02e56377755f962742e8981e7bbba"
   dependencies:
@@ -816,7 +816,7 @@ bluebird@^2.10.0:
   version "2.11.0"
   resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1"
 
-bluebird@^3.0.5, bluebird@^3.3.4, bluebird@^3.4.6, bluebird@^3.4.7, bluebird@^3.5.0, bluebird@^3.5.1:
+bluebird@^3.0.5, bluebird@^3.3.4, bluebird@^3.4.6, bluebird@^3.4.7, bluebird@^3.5.0:
   version "3.5.1"
   resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"
 
@@ -5154,17 +5154,6 @@ oauth2-server@3.0.0:
     statuses "1.3.1"
     type-is "1.6.15"
 
-oauth2-server@^3.0.0:
-  version "3.0.1"
-  resolved "https://registry.yarnpkg.com/oauth2-server/-/oauth2-server-3.0.1.tgz#8fdb7eb78f107832f75c554cb42e59a3f37e41ea"
-  dependencies:
-    basic-auth "^2.0.0"
-    bluebird "^3.5.1"
-    lodash "^4.17.10"
-    promisify-any "^2.0.1"
-    statuses "^1.5.0"
-    type-is "^1.6.16"
-
 object-assign@4.1.0:
   version "4.1.0"
   resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0"
@@ -5703,7 +5692,7 @@ promise@^7.1.1:
   dependencies:
     asap "~2.0.3"
 
-promisify-any@2.0.1, promisify-any@^2.0.1:
+promisify-any@2.0.1:
   version "2.0.1"
   resolved "https://registry.yarnpkg.com/promisify-any/-/promisify-any-2.0.1.tgz#403e00a8813f175242ab50fe33a69f8eece47305"
   dependencies:
@@ -6849,7 +6838,7 @@ static-extend@^0.1.1:
     define-property "^0.2.5"
     object-copy "^0.1.0"
 
-statuses@1, "statuses@>= 1.3.1 < 2", "statuses@>= 1.4.0 < 2", statuses@^1.5.0:
+statuses@1, "statuses@>= 1.3.1 < 2", "statuses@>= 1.4.0 < 2":
   version "1.5.0"
   resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
 
@@ -7439,7 +7428,7 @@ type-is@1.6.15:
     media-typer "0.3.0"
     mime-types "~2.1.15"
 
-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:
+type-is@^1.6.4, type-is@~1.6.15, type-is@~1.6.16, type-is@~1.6.6:
   version "1.6.16"
   resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194"
   dependencies: