fix(plans): possible safe-check of gemcapextra cc @Sabrecat

This commit is contained in:
Tyler Renelle 2014-12-03 20:03:40 -07:00
parent cb8c1359c4
commit 9d3e6c71fe
2 changed files with 5 additions and 1 deletions

View file

@ -15062,10 +15062,13 @@ api.wrap = function(user, main) {
return typeof cb === "function" ? cb(null, _.pick(user, $w('items stats'))) : void 0;
},
purchase: function(req, cb, ga) {
var convCap, convRate, item, key, type, _ref, _ref1, _ref2;
var convCap, convRate, item, key, type, _base, _ref, _ref1, _ref2;
_ref = req.params, type = _ref.type, key = _ref.key;
if (type === 'gems' && key === 'gem') {
convRate = api.planGemLimits.convRate;
if ((_base = user.purchased.plan.consecutive).gemCapExtra == null) {
_base.gemCapExtra = 0;
}
convCap = api.planGemLimits + user.purchased.plan.consecutive.gemCapExtra;
if (!((_ref1 = user.purchased) != null ? (_ref2 = _ref1.plan) != null ? _ref2.planId : void 0 : void 0)) {
return typeof cb === "function" ? cb({

View file

@ -695,6 +695,7 @@ api.wrap = (user, main=true) ->
if type is 'gems' and key is 'gem'
{convRate} = api.planGemLimits
user.purchased.plan.consecutive.gemCapExtra ?= 0 #fixme this necessary?
convCap = api.planGemLimits + user.purchased.plan.consecutive.gemCapExtra
return cb?({code:401,message:"Must subscribe to purchase gems with GP"},req) unless user.purchased?.plan?.planId
return cb?({code:401,message:"Not enough Gold"}) unless user.stats.gp >= convRate