1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Server: Use ES6 promise for mongoose/node-oatuh2-server

This commit is contained in:
Chocobozzz 2016-07-27 21:15:07 +02:00
parent f24c4e4462
commit 32bb415602
4 changed files with 9 additions and 9 deletions

View file

@ -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
})
}