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/models/oauth-client.js | 2 +- server/models/oauth-token.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'server/models') diff --git a/server/models/oauth-client.js b/server/models/oauth-client.js index 830f68857..45834c5a5 100644 --- a/server/models/oauth-client.js +++ b/server/models/oauth-client.js @@ -29,5 +29,5 @@ function loadFirstClient (callback) { } function getByIdAndSecret (id, clientSecret) { - return this.findOne({ _id: id, clientSecret: clientSecret }) + return this.findOne({ _id: id, clientSecret: clientSecret }).exec() } diff --git a/server/models/oauth-token.js b/server/models/oauth-token.js index 23c698732..f6a814c36 100644 --- a/server/models/oauth-token.js +++ b/server/models/oauth-token.js @@ -28,7 +28,7 @@ mongoose.model('OAuthToken', OAuthTokenSchema) // --------------------------------------------------------------------------- function getByRefreshTokenAndPopulateClient (refreshToken) { - return this.findOne({ refreshToken: refreshToken }).populate('client').then(function (token) { + return this.findOne({ refreshToken: refreshToken }).populate('client').exec().then(function (token) { if (!token) return token const tokenInfos = { @@ -47,9 +47,9 @@ function getByRefreshTokenAndPopulateClient (refreshToken) { } function getByTokenAndPopulateUser (bearerToken) { - return this.findOne({ accessToken: bearerToken }).populate('user') + return this.findOne({ accessToken: bearerToken }).populate('user').exec() } function getByRefreshToken (refreshToken) { - return this.findOne({ refreshToken: refreshToken }) + return this.findOne({ refreshToken: refreshToken }).exec() } -- cgit v1.2.3