0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Added custom integration feature limit

refs: https://github.com/TryGhost/Team/issues/510

- in the case that host config is provided, prevents the creation of custom integrations
This commit is contained in:
Hannah Wolfe 2021-03-03 12:47:30 +00:00
parent cb43a8e3a8
commit edb626af18
2 changed files with 14 additions and 1 deletions

View file

@ -1,3 +1,4 @@
const limitService = require('../services/limits');
const ghostBookshelf = require('./base');
const Integration = ghostBookshelf.Model.extend({
@ -60,6 +61,17 @@ const Integration = ghostBookshelf.Model.extend({
}
return options;
},
async permissible(integrationModel, action) {
const isAdd = (action === 'add');
if (isAdd && limitService.isLimited('custom_integrations')) {
// CASE: if your site is limited to a certain number of custom integrations
// Inviting a new custom integration requires we check we won't go over the limit
await limitService.errorIfWouldGoOverLimit('custom_integrations');
}
return true;
}
});

View file

@ -20,7 +20,8 @@ CanThisResult.prototype.buildObjectTypeHandlers = function (objTypes, actType, c
user: models.User,
permission: models.Permission,
setting: models.Settings,
invite: models.Invite
invite: models.Invite,
integration: models.Integration
};
// Iterate through the object types, i.e. ['post', 'tag', 'user']