diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-07-27 21:15:07 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-07-27 21:16:19 +0200 |
commit | 32bb41560279dd0c75d0461f081873483e3aaed9 (patch) | |
tree | ef4d621d7f9f5ffcadf437da0e872042312305bc /server/lib | |
parent | f24c4e44624058e16d4a09856fac8c409203c59f (diff) | |
download | PeerTube-32bb41560279dd0c75d0461f081873483e3aaed9.tar.gz PeerTube-32bb41560279dd0c75d0461f081873483e3aaed9.tar.zst PeerTube-32bb41560279dd0c75d0461f081873483e3aaed9.zip |
Server: Use ES6 promise for mongoose/node-oatuh2-server
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/oauth-model.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/server/lib/oauth-model.js b/server/lib/oauth-model.js index 555a54e90..d9f8b175a 100644 --- a/server/lib/oauth-model.js +++ b/server/lib/oauth-model.js | |||
@@ -62,7 +62,7 @@ function revokeToken (token) { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | function saveToken (token, client, user) { | 64 | function saveToken (token, client, user) { |
65 | logger.debug('Saving token for client ' + client.id + ' and user ' + user.id + '.') | 65 | logger.debug('Saving token ' + token.accessToken + ' for client ' + client.id + ' and user ' + user.id + '.') |
66 | 66 | ||
67 | const tokenObj = new OAuthToken({ | 67 | const tokenObj = new OAuthToken({ |
68 | accessToken: token.accessToken, | 68 | accessToken: token.accessToken, |
@@ -73,13 +73,12 @@ function saveToken (token, client, user) { | |||
73 | user: user.id | 73 | user: user.id |
74 | }) | 74 | }) |
75 | 75 | ||
76 | return tokenObj.save(function (err, tokenCreated) { | 76 | return tokenObj.save().then(function (tokenCreated) { |
77 | if (err) throw err // node-oauth2-server library uses Promise.try | ||
78 | |||
79 | tokenCreated.client = client | 77 | tokenCreated.client = client |
80 | tokenCreated.user = user | 78 | tokenCreated.user = user |
81 | |||
82 | return tokenCreated | 79 | return tokenCreated |
80 | }).catch(function (err) { | ||
81 | throw err | ||
83 | }) | 82 | }) |
84 | } | 83 | } |
85 | 84 | ||