From 32bb41560279dd0c75d0461f081873483e3aaed9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Jul 2016 21:15:07 +0200 Subject: Server: Use ES6 promise for mongoose/node-oatuh2-server --- server/lib/oauth-model.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'server/lib') 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) { } function saveToken (token, client, user) { - logger.debug('Saving token for client ' + client.id + ' and user ' + user.id + '.') + logger.debug('Saving token ' + token.accessToken + ' for client ' + client.id + ' and user ' + user.id + '.') const tokenObj = new OAuthToken({ accessToken: token.accessToken, @@ -73,13 +73,12 @@ function saveToken (token, client, user) { user: user.id }) - return tokenObj.save(function (err, tokenCreated) { - if (err) throw err // node-oauth2-server library uses Promise.try - + return tokenObj.save().then(function (tokenCreated) { tokenCreated.client = client tokenCreated.user = user - return tokenCreated + }).catch(function (err) { + throw err }) } -- cgit v1.2.3