mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-19 23:10:21 +01:00
feat(config): add acpPluginInstallDisabled option (#13189)
This commit is contained in:
@@ -268,6 +268,7 @@
|
|||||||
|
|
||||||
"invalid-plugin-id": "Invalid plugin ID",
|
"invalid-plugin-id": "Invalid plugin ID",
|
||||||
"plugin-not-whitelisted": "Unable to install plugin – only plugins whitelisted by the NodeBB Package Manager can be installed via the ACP",
|
"plugin-not-whitelisted": "Unable to install plugin – only plugins whitelisted by the NodeBB Package Manager can be installed via the ACP",
|
||||||
|
"plugin-installation-via-acp-disabled": "Plugin installation via ACP is disabled",
|
||||||
"plugins-set-in-configuration": "You are not allowed to change plugin state as they are defined at runtime (config.json, environmental variables or terminal arguments), please modify the configuration instead.",
|
"plugins-set-in-configuration": "You are not allowed to change plugin state as they are defined at runtime (config.json, environmental variables or terminal arguments), please modify the configuration instead.",
|
||||||
"theme-not-set-in-configuration": "When defining active plugins in configuration, changing themes requires adding the new theme to the list of active plugins before updating it in the ACP",
|
"theme-not-set-in-configuration": "When defining active plugins in configuration, changing themes requires adding the new theme to the list of active plugins before updating it in the ACP",
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ get:
|
|||||||
type: boolean
|
type: boolean
|
||||||
jobsDisabled:
|
jobsDisabled:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
acpPluginInstallDisabled:
|
||||||
|
type: boolean
|
||||||
git:
|
git:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ async function getNodeInfo() {
|
|||||||
isPrimary: nconf.get('isPrimary'),
|
isPrimary: nconf.get('isPrimary'),
|
||||||
runJobs: nconf.get('runJobs'),
|
runJobs: nconf.get('runJobs'),
|
||||||
jobsDisabled: nconf.get('jobsDisabled'),
|
jobsDisabled: nconf.get('jobsDisabled'),
|
||||||
|
acpPluginInstallDisabled: nconf.get('acpPluginInstallDisabled')
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ function loadConfig(configFile) {
|
|||||||
isCluster: false,
|
isCluster: false,
|
||||||
isPrimary: true,
|
isPrimary: true,
|
||||||
jobsDisabled: false,
|
jobsDisabled: false,
|
||||||
|
acpPluginInstallDisabled: false,
|
||||||
fontawesome: {
|
fontawesome: {
|
||||||
pro: false,
|
pro: false,
|
||||||
styles: '*',
|
styles: '*',
|
||||||
@@ -65,7 +66,7 @@ function loadConfig(configFile) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Explicitly cast as Bool, loader.js passes in isCluster as string 'true'/'false'
|
// Explicitly cast as Bool, loader.js passes in isCluster as string 'true'/'false'
|
||||||
const castAsBool = ['isCluster', 'isPrimary', 'jobsDisabled'];
|
const castAsBool = ['isCluster', 'isPrimary', 'jobsDisabled', 'acpPluginInstallDisabled'];
|
||||||
nconf.stores.env.readOnly = false;
|
nconf.stores.env.readOnly = false;
|
||||||
castAsBool.forEach((prop) => {
|
castAsBool.forEach((prop) => {
|
||||||
const value = nconf.get(prop);
|
const value = nconf.get(prop);
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ Plugins.toggleActive = async function (socket, plugin_id) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Plugins.toggleInstall = async function (socket, data) {
|
Plugins.toggleInstall = async function (socket, data) {
|
||||||
|
const isInstalled = await plugins.isInstalled(data.id);
|
||||||
|
if (nconf.get('acpPluginInstallDisabled') && !isInstalled) {
|
||||||
|
throw new Error('[[error:plugin-installation-via-acp-disabled]]');
|
||||||
|
}
|
||||||
postsCache.reset();
|
postsCache.reset();
|
||||||
await plugins.checkWhitelist(data.id, data.version);
|
await plugins.checkWhitelist(data.id, data.version);
|
||||||
const pluginData = await plugins.toggleInstall(data.id, data.version);
|
const pluginData = await plugins.toggleInstall(data.id, data.version);
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ before(async function () {
|
|||||||
nconf.set('version', packageInfo.version);
|
nconf.set('version', packageInfo.version);
|
||||||
nconf.set('runJobs', false);
|
nconf.set('runJobs', false);
|
||||||
nconf.set('jobsDisabled', false);
|
nconf.set('jobsDisabled', false);
|
||||||
|
nconf.set('acpPluginInstallDisabled', false);
|
||||||
|
|
||||||
|
|
||||||
await db.init();
|
await db.init();
|
||||||
|
|||||||
Reference in New Issue
Block a user