Skip to content

Commit

Permalink
Populate default features array even during init
Browse files Browse the repository at this point in the history
  • Loading branch information
fdel-car committed Jan 25, 2023
1 parent e1e812d commit 0609de2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 0 additions & 10 deletions packages/core/strapi/ee/index.js
Expand Up @@ -7,11 +7,6 @@ const { eeStoreModel } = require('./ee-store');
const { shiftCronExpression } = require('../lib/utils/cron');

const ONE_MINUTE = 1000 * 60;
const DEFAULT_FEATURES = {
bronze: [],
silver: [],
gold: ['sso'],
};

const ee = {
enabled: false,
Expand Down Expand Up @@ -126,12 +121,7 @@ const validateInfo = () => {
return disable('License expired.');
}

if (!ee.licenseInfo.features) {
ee.licenseInfo.features = DEFAULT_FEATURES[ee.licenseInfo.type];
}

ee.enabled = true;
Object.freeze(ee.licenseInfo.features);
};

const checkLicense = async ({ strapi }) => {
Expand Down
15 changes: 14 additions & 1 deletion packages/core/strapi/ee/license.js
Expand Up @@ -5,6 +5,12 @@ const { join } = require('path');
const crypto = require('crypto');
const fetch = require('node-fetch');

const DEFAULT_FEATURES = {
bronze: [],
silver: [],
gold: ['sso'],
};

const publicKey = fs.readFileSync(join(__dirname, 'resources/key.pub'));

class LicenseCheckError extends Error {
Expand Down Expand Up @@ -45,7 +51,14 @@ const verifyLicense = (license) => {
throw new Error('Invalid license.');
}

return JSON.parse(stringifiedContent);
const licenseInfo = JSON.parse(stringifiedContent);

if (!licenseInfo.features) {
licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];
}

Object.freeze(licenseInfo.features);
return licenseInfo;
};

const throwError = () => {
Expand Down

0 comments on commit 0609de2

Please sign in to comment.