Add plugin "type" to plugins (permission sets coming soon)

This commit is contained in:
Ryan Blenis 2019-11-11 09:46:38 -05:00
parent 06cbf93934
commit 6d3673a858
2 changed files with 3 additions and 3 deletions

4
db.js
View File

@ -753,10 +753,10 @@ module.exports.CreateDB = function (parent, func) {
}
// Add a plugin
obj.addPlugin = function (plugin, func) { obj.pluginsfile.insertOne(plugin, func); };
obj.addPlugin = function (plugin, func) { plugin.type = "plugin"; obj.pluginsfile.insertOne(plugin, func); };
// Get all plugins
obj.getPlugins = function (func) { obj.pluginsfile.find().sort({ name: 1 }).toArray(func); };
obj.getPlugins = function (func) { obj.pluginsfile.find({"type": "plugin"}).project({"type": 0}).sort({ name: 1 }).toArray(func); };
// Get plugin
obj.getPlugin = function (id, func) { id = require('mongodb').ObjectID(id); obj.pluginsfile.find({ _id: id }).sort({ name: 1 }).toArray(func); };

View File

@ -3113,7 +3113,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
break;
}
case 'plugins': {
// @Ylianst - Do we need a new permission set here?
// Since plugin actions generally require a server restart, use the Full admin permission
if ((user.siteadmin & 0xFFFFFFFF) == 0 || parent.parent.pluginHandler == null) break; // must be full admin with plugins enabled
parent.db.getPlugins(function(err, docs) {
try { ws.send(JSON.stringify({ action: 'updatePluginList', list: docs, result: err })); } catch (ex) { }