mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
Merge branch 'chore/ee-seats' of https://github.com/strapi/strapi into chore/ee-seats
This commit is contained in:
commit
c4620fd18a
@ -6,7 +6,9 @@ const { getService } = require('../../../server/utils');
|
||||
module.exports = {
|
||||
async licenseLimitInformation() {
|
||||
const permittedSeats = strapi.ee.licenseInfo.seats;
|
||||
if (!permittedSeats) return;
|
||||
if (!permittedSeats) {
|
||||
return;
|
||||
}
|
||||
|
||||
let shouldNotify = false;
|
||||
let licenseLimitStatus = null;
|
||||
|
@ -6,7 +6,9 @@ const { getService } = require('../../../server/utils');
|
||||
const enableUsersToLicenseLimit = async (numberOfUsersToEnable) => {
|
||||
const data = await getService('user').getDisabledUserList();
|
||||
|
||||
if (!data || !data.value || data.value.length === 0) return;
|
||||
if (!data?.value || data.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const disabledUsers = JSON.parse(data.value);
|
||||
|
||||
@ -64,7 +66,7 @@ const disableUsersAboveLicenseLimit = async (numberOfUsersToDisable) => {
|
||||
});
|
||||
|
||||
if (data) {
|
||||
return strapi.db.query('strapi::ee-store').update({
|
||||
await strapi.db.query('strapi::ee-store').update({
|
||||
where: { id: data.id },
|
||||
data: { value: JSON.stringify(usersToDisable) },
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { filter, pipe, castArray, map, toNumber } = require('lodash/fp');
|
||||
const { pipe, castArray, map, toNumber } = require('lodash/fp');
|
||||
|
||||
/** Checks if ee disabled users list needs to be updated
|
||||
* @param {string} id
|
||||
@ -11,13 +11,17 @@ const shouldUpdateEEDisabledUsersList = async (id, input) => {
|
||||
where: { key: 'ee_disabled_users' },
|
||||
});
|
||||
|
||||
if (!data || !data.value || data.value.length === 0) return;
|
||||
if (!data?.value || data.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
const disabledUsers = JSON.parse(data.value);
|
||||
const user = disabledUsers.find((user) => user.id === Number(id));
|
||||
if (!user) return;
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.isActive !== input.isActive) {
|
||||
const newDisabledUsersList = filter(disabledUsers, (user) => user.id !== Number(id));
|
||||
const newDisabledUsersList = disabledUsers.filter((user) => user.id !== Number(id));
|
||||
await strapi.db.query('strapi::ee-store').update({
|
||||
where: { id: data.id },
|
||||
data: { value: JSON.stringify(newDisabledUsersList) },
|
||||
@ -39,10 +43,12 @@ const shouldRemoveFromEEDisabledUsersList = async (ids) => {
|
||||
where: { key: 'ee_disabled_users' },
|
||||
});
|
||||
|
||||
if (!data || !data.value || data.value.length === 0) return;
|
||||
if (!data?.value || data.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
const disabledUsers = JSON.parse(data.value);
|
||||
|
||||
const newDisabledUsersList = filter(disabledUsers, (user) => !idsToCheck.includes(user.id));
|
||||
const newDisabledUsersList = disabledUsers.filter((user) => !idsToCheck.includes(user.id));
|
||||
await strapi.db.query('strapi::ee-store').update({
|
||||
where: { id: data.id },
|
||||
data: { value: JSON.stringify(newDisabledUsersList) },
|
||||
|
@ -1,19 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
const utils = require('@strapi/utils');
|
||||
const { ApplicationError } = require('@strapi/utils/lib/errors');
|
||||
|
||||
const { PolicyError } = utils.errors;
|
||||
|
||||
module.exports = async (policyCtx, config = {}) => {
|
||||
if (!strapi.EE) return true;
|
||||
if (!strapi.EE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const permittedSeats = strapi.ee.licenseInfo.seats;
|
||||
if (!permittedSeats) return true;
|
||||
if (!permittedSeats) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const userCount = await strapi.service('admin::user').getCurrentActiveUserCount();
|
||||
|
||||
if (userCount < permittedSeats) return true;
|
||||
if (userCount < permittedSeats) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (userCount >= permittedSeats && config.isCreating) {
|
||||
throw new PolicyError("License seat limit reached, can't create new user", {
|
||||
policy: 'license-limit-allowance',
|
||||
@ -23,7 +29,7 @@ module.exports = async (policyCtx, config = {}) => {
|
||||
const user = await strapi.service('admin::user').findOne(policyCtx.params.id);
|
||||
|
||||
if (!user) {
|
||||
throw new ApplicationError('User could not be found');
|
||||
return true; // Delegate not found to the controller
|
||||
}
|
||||
|
||||
if (
|
||||
|
Loading…
x
Reference in New Issue
Block a user