diff --git a/lib/model.js b/lib/model.js index 061701c..cc51adf 100644 --- a/lib/model.js +++ b/lib/model.js @@ -114,11 +114,11 @@ Model = module.exports = emitter.spawn({ strict: true, allowed: { - read: 'super-user', - write: 'super-user', - remove: 'super-user', + read: 'root', + write: 'root', + remove: 'root', special: { - _id: 'super-user' + _id: 'root' } }, @@ -310,7 +310,13 @@ Model = module.exports = emitter.spawn({ if(this.description) { settings .find({name: this.name || this.collection, plugin: this.plugin}) - .set({name: this.name || this.collection, description: this.description, plugin: this.plugin}) + .set({ + name: this.name || this.collection, + description: this.description, + plugin: this.plugin, + collection: this.collection, + allowed: this.allowed + }) .notify(function(json) { if(json) { delete json._id; @@ -321,7 +327,6 @@ Model = module.exports = emitter.spawn({ _self.configure(_self.description, function(err) { if(err) console.error(err); }); - } }) .save() diff --git a/lib/plugins/settings/index.js b/lib/plugins/settings/index.js index c772c96..b8a75a5 100644 --- a/lib/plugins/settings/index.js +++ b/lib/plugins/settings/index.js @@ -13,6 +13,17 @@ app.get('/settings', function(req, res) { ; }); +app.post('/settings', function(req, res) { + Settings + .spawn() + .for(req) + .find({name: req.body.name, plugin: req.body.name}) + .set(req.body) + .notify(res) + .save() + ; +}); + app.get('/settings/:name', function(req, res) { Setting .spawn() @@ -23,19 +34,11 @@ app.get('/settings/:name', function(req, res) { ; }); -var Model = require('../../model').spawn(); -Model.unlock(); -Model.collection = 'system.indexes'; -Model.notify(function(data) { - config.indexes = data; - - Setting - .spawn() - .find({name: 'app'}) - .set(config) - .set({name: 'app'}) - .save() - ; -}).fetch(); - -// create or update app settings +// create or update general app settings +Setting + .spawn() + .find({name: 'app'}) + .set(config) + .set({name: 'app'}) + .save() +;