aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/oauth-model.js9
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
64function saveToken (token, client, user) { 64function 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