From 6e27b7af9d57af252e0d31e78da51f799d7f797b Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 13 May 2015 15:15:40 -0500 Subject: [PATCH] fix(purchases): Handle undefined/null balance --- common/script/index.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/script/index.coffee b/common/script/index.coffee index f5d49a1df1..10e3acc352 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -750,7 +750,7 @@ api.wrap = (user, main=true) -> item = content[type][key] price = item.value / 4 return cb?({code:404,message:":key not found for Content.#{type}"},req) unless item - return cb?({code:401, message: i18n.t('notEnoughGems', req.language)}) if user.balance < price + return cb?({code:401, message: i18n.t('notEnoughGems', req.language)}) if (user.balance < price) or !user.balance user.balance -= price if type is 'gear' then user.items.gear.owned[key] = true else