prevent buying market gear if class doesn't match (#10818)

* prevent buying market gear if class doesn't match

* add test
This commit is contained in:
negue
2018-11-12 21:32:54 +01:00
committed by Matteo Pagliazzi
parent be95cd967a
commit eca7382545
2 changed files with 20 additions and 0 deletions

View File

@@ -24,6 +24,15 @@ export class BuyMarketGearOperation extends AbstractGoldItemOperation {
return false;
}
canUserPurchase (user, item) {
super.canUserPurchase(user, item);
// check for different class gear
if (item.klass !== 'special' && item.klass !== user.stats.class) {
throw new NotAuthorized(this.i18n('cannotBuyItem'));
}
}
extractAndValidateParams (user, req) {
let key = this.key = get(req, 'params.key');
if (!key) throw new BadRequest(errorMessage('missingKeyParam'));