mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
fix(purchases): Handle undefined/null balance
This commit is contained in:
parent
68ce9a8457
commit
6e27b7af9d
1 changed files with 1 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue