mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
feat(config): add acpPluginInstallDisabled option (#13189)
This commit is contained in:
@@ -268,6 +268,7 @@
|
||||
|
||||
"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-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.",
|
||||
"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
|
||||
jobsDisabled:
|
||||
type: boolean
|
||||
acpPluginInstallDisabled:
|
||||
type: boolean
|
||||
git:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@@ -88,6 +88,7 @@ async function getNodeInfo() {
|
||||
isPrimary: nconf.get('isPrimary'),
|
||||
runJobs: nconf.get('runJobs'),
|
||||
jobsDisabled: nconf.get('jobsDisabled'),
|
||||
acpPluginInstallDisabled: nconf.get('acpPluginInstallDisabled')
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ function loadConfig(configFile) {
|
||||
isCluster: false,
|
||||
isPrimary: true,
|
||||
jobsDisabled: false,
|
||||
acpPluginInstallDisabled: false,
|
||||
fontawesome: {
|
||||
pro: false,
|
||||
styles: '*',
|
||||
@@ -65,7 +66,7 @@ function loadConfig(configFile) {
|
||||
});
|
||||
|
||||
// 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;
|
||||
castAsBool.forEach((prop) => {
|
||||
const value = nconf.get(prop);
|
||||
|
||||
@@ -22,6 +22,10 @@ Plugins.toggleActive = async function (socket, plugin_id) {
|
||||
};
|
||||
|
||||
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();
|
||||
await plugins.checkWhitelist(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('runJobs', false);
|
||||
nconf.set('jobsDisabled', false);
|
||||
nconf.set('acpPluginInstallDisabled', false);
|
||||
|
||||
|
||||
await db.init();
|
||||
|
||||
Reference in New Issue
Block a user