diff --git a/public/js/controllers/tasksCtrl.js b/public/js/controllers/tasksCtrl.js index 399899d911..cd8a10e1cf 100644 --- a/public/js/controllers/tasksCtrl.js +++ b/public/js/controllers/tasksCtrl.js @@ -116,7 +116,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User', ' $scope.buy = function(type) { var hasEnough = window.habitrpgShared.items.buyItem(User.user, type); if (hasEnough) { - User.log({op: "buy",type: type}); + User.log({op: "buy", type: type}); Notification.text("Item purchased."); updateStore(); } else { diff --git a/src/controllers/user.js b/src/controllers/user.js index b453d2c914..aefa137942 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -204,8 +204,8 @@ api.clearCompleted = function(req, res, next) { */ api.buy = function(req, res, next) { var user = res.locals.user; - var item = req.params.item; - if (item !== 'potion' && !items.items.gear.flat[item]) { + var type = req.params.type; + if (!type.match(/potion|weapon|armor|head|shield/)) { // if (item !== 'potion' && !items.items.gear.flat[item]) return res.json(400, {err: ":item must be a supported key, see https://github.com/HabitRPG/habitrpg-shared/blob/master/script/items.coffee"}); } var hasEnough = items.buyItem(user, type); diff --git a/src/routes/api.js b/src/routes/api.js index 209a183313..34c3c3327d 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -48,7 +48,7 @@ if (nconf.get('NODE_ENV') == 'development') { } /* Items*/ -router.post('/user/buy/:item', auth.auth, cron, user.buy); +router.post('/user/buy/:type', auth.auth, cron, user.buy); /* User*/ router.get('/user', auth.auth, cron, user.getUser);