fix(unlocks): Handle undefined/null balance

This commit is contained in:
Sabe Jones 2015-05-13 15:34:23 -05:00
parent 6e27b7af9d
commit 84b333e5c1

View file

@ -892,7 +892,7 @@ api.wrap = (user, main=true) ->
else else
if fullSet then 1.25 else 0.5 if fullSet then 1.25 else 0.5
alreadyOwns = !fullSet and user.fns.dotGet("purchased." + path) is true alreadyOwns = !fullSet and user.fns.dotGet("purchased." + path) is true
return cb?({code:401, message: i18n.t('notEnoughGems', req.language)}) if user.balance < cost and !alreadyOwns return cb?({code:401, message: i18n.t('notEnoughGems', req.language)}) if (user.balance < cost or !user.balance) and !alreadyOwns
if fullSet if fullSet
_.each path.split(","), (p) -> _.each path.split(","), (p) ->
if ~path.indexOf('gear.') if ~path.indexOf('gear.')