fix: fix quest shop to not use string addition when buying quests (#10120)

* fix: fix quest shop to not use string addition when buying quests

fixes #10115

* Fixing quest purchase quantity interpretted as a string on the server side.

* Adjusting pull-request according to comments.

* Updating according to PR comments.
This commit is contained in:
Travis
2018-03-24 09:17:23 -07:00
committed by Sabe Jones
parent dcd680c293
commit 781256c917
6 changed files with 58 additions and 3 deletions
+3 -1
View File
@@ -10,7 +10,9 @@ import get from 'lodash/get';
// buy a quest with gold
module.exports = function buyQuest (user, req = {}, analytics) {
let key = get(req, 'params.key');
let quantity = req.quantity || 1;
let quantity = req.quantity ? Number(req.quantity) : 1;
if (isNaN(quantity)) throw new BadRequest(i18n.t('invalidQuantity', req.language));
if (!key) throw new BadRequest(i18n.t('missingKeyParam', req.language));
+3 -1
View File
@@ -109,7 +109,9 @@ function purchaseItem (user, item, price, type, key) {
module.exports = function purchase (user, req = {}, analytics) {
let type = get(req.params, 'type');
let key = get(req.params, 'key');
let quantity = req.quantity || 1;
let quantity = req.quantity ? Number(req.quantity) : 1;
if (isNaN(quantity)) throw new BadRequest(i18n.t('invalidQuantity', req.language));
if (!type) {
throw new BadRequest(i18n.t('typeRequired', req.language));