demo: limit to 20 apps

This commit is contained in:
Girish Ramakrishnan
2021-11-15 13:55:29 -08:00
parent aa3ee2e180
commit 9c096b18e1
2 changed files with 8 additions and 0 deletions

View File

@@ -1162,6 +1162,11 @@ async function validateLocations(locations) {
return domainObjectMap;
}
async function getCount() {
const result = await database.query('SELECT COUNT(*) AS total FROM apps');
return result[0].total;
}
async function install(data, auditSource) {
assert(data && typeof data === 'object');
assert.strictEqual(typeof auditSource, 'object');
@@ -1237,6 +1242,8 @@ async function install(data, auditSource) {
const domainObjectMap = await validateLocations(locations);
if (settings.isDemo() && getCount() >= constants.DEMO_APP_LIMIT) throw new BoxError(BoxError.BAD_STATE, 'Too many installed apps, please uninstall a few and try again');
const appId = uuid.v4();
debug('Will install app with id : ' + appId);