defend against undefined plan_code

This commit is contained in:
Shane Kilkelly 2016-08-17 08:51:35 +01:00
parent 81d0edf716
commit fc068b62a2

View file

@ -170,6 +170,10 @@ module.exports = SubscriptionController =
AuthenticationController.getLoggedInUser req, (error, user) -> AuthenticationController.getLoggedInUser req, (error, user) ->
return next(error) if error? return next(error) if error?
planCode = req.body.plan_code planCode = req.body.plan_code
if !planCode?
err = new Error('plan_code not defined')
logger.err {user_id: user._id, err}, "error updating subscription"
return next(err)
logger.log planCode: planCode, user_id:user._id, "updating subscription" logger.log planCode: planCode, user_id:user._id, "updating subscription"
SubscriptionHandler.updateSubscription user, planCode, null, (err)-> SubscriptionHandler.updateSubscription user, planCode, null, (err)->
if err? if err?