From 6cf7160f659bba239ead5dce370c121d9bb04463 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Wed, 29 Jan 2014 15:55:02 +0100 Subject: [PATCH] fix(purchase) add a check for user.balance --- script/index.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/script/index.coffee b/script/index.coffee index 0be3a87225..19dfe29bbf 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -586,6 +586,7 @@ api.wrap = (user, main=true) -> return cb?({code:404,message:":type must be in [hatchingPotions,eggs,food,quests,special]"},req) unless type in ['eggs','hatchingPotions','food','quests','special'] item = content[type][key] return cb?({code:404,message:":key not found for Content.#{type}"},req) unless item + return cb?({code:401, message:'Not enough gems.'}) if user.balance < (item.value / 4) user.items[type][key] = 0 unless user.items[type][key] user.items[type][key]++ user.balance -= (item.value / 4)