From 5cd42e85c7fbdbc1b545965f61fe78de5f8a93dd Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Fri, 24 Jul 2015 10:35:03 -0500 Subject: [PATCH] bail out and alert user if prize is too high --- website/public/js/controllers/challengesCtrl.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/website/public/js/controllers/challengesCtrl.js b/website/public/js/controllers/challengesCtrl.js index 5e885e4f43..3a34b4b48f 100644 --- a/website/public/js/controllers/challengesCtrl.js +++ b/website/public/js/controllers/challengesCtrl.js @@ -114,9 +114,13 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', */ $scope.save = function(challenge) { if (!challenge.group) return alert(window.env.t('selectGroup')); + var isNew = !challenge._id; - $scope.hasEnoughGems(challenge.group); - if (!$scope.enoughGems && isNew ) return alert(window.env.t('challengeNotEnoughGems')); + + if(isNew && challenge.prize > $scope.maxPrize) { + return alert(window.env.t('challengeNotEnoughGems')); + } + challenge.$save(function(_challenge){ if (isNew) { Notification.text(window.env.t('challengeCreated'));