2014-02-12 05:23:40 -05:00
|
|
|
logger = require("logger-sharelatex")
|
|
|
|
User = require('../../models/User').User
|
|
|
|
PlansLocator = require("./PlansLocator")
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
updateFeatures: (user_id, plan_code, callback = (err, features)->)->
|
|
|
|
conditions = _id:user_id
|
|
|
|
update = {}
|
|
|
|
plan = PlansLocator.findLocalPlanInSettings(plan_code)
|
2016-02-19 07:27:01 -05:00
|
|
|
logger.log user_id:user_id, features:plan.features, plan_code:plan_code, "updating users features"
|
2014-02-12 05:23:40 -05:00
|
|
|
update["features.#{key}"] = value for key, value of plan.features
|
|
|
|
User.update conditions, update, (err)->
|
|
|
|
callback err, plan.features
|
|
|
|
|