Groups can prevent members from getting gems (#8870)

* add possibility for group to block members from getting gems

* fixes

* fix tests

* adds some tests

* unit tests

* finish unit tests

* remove old code
This commit is contained in:
Matteo Pagliazzi
2017-07-16 18:23:57 +02:00
committed by Sabe Jones
parent fe9521a63f
commit 78ba596504
20 changed files with 339 additions and 16 deletions

View File

@@ -30,6 +30,11 @@ module.exports = function purchase (user, req = {}, analytics) {
let convCap = planGemLimits.convCap;
convCap += user.purchased.plan.consecutive.gemCapExtra;
// Some groups limit their members ability to obtain gems
// The check is async so it's done on the server (in server/controllers/api-v3/user#purchase)
// only and not on the client,
// resulting in a purchase that will seem successful until the request hit the server.
if (!user.purchased || !user.purchased.plan || !user.purchased.plan.customerId) {
throw new NotAuthorized(i18n.t('mustSubscribeToPurchaseGems', req.language));
}