Merge pull request #2387 from overleaf/jel-async-login

Convert V1LoginController._login to async

GitOrigin-RevId: 2e51533126919f5a4ce71ca5d403a24773375333
This commit is contained in:
Jessica Lawshe 2019-11-25 07:29:40 -06:00 committed by sharelatex
parent 0866b9de9b
commit 1a456da017

View file

@ -12,7 +12,6 @@
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
let FeaturesUpdater
const async = require('async')
const PlansLocator = require('./PlansLocator')
const _ = require('underscore')
@ -27,7 +26,7 @@ const UserGetter = require('../User/UserGetter')
const oneMonthInSeconds = 60 * 60 * 24 * 30
module.exports = FeaturesUpdater = {
const FeaturesUpdater = {
refreshFeatures(user_id, callback) {
if (callback == null) {
callback = function(error, features, featuresChanged) {}
@ -227,3 +226,23 @@ module.exports = FeaturesUpdater = {
}
}
}
const refreshFeaturesPromise = user_id =>
new Promise(function(resolve, reject) {
FeaturesUpdater.refreshFeatures(
user_id,
(error, features, featuresChanged) => {
if (error) {
reject(error)
} else {
resolve({ features, featuresChanged })
}
}
)
})
FeaturesUpdater.promises = {
refreshFeatures: refreshFeaturesPromise
}
module.exports = FeaturesUpdater