salix/services/loopback/server/boot/root.js

41 lines
967 B
JavaScript
Raw Normal View History

2017-10-13 14:22:45 +00:00
module.exports = function(app) {
let models = app.models();
models.forEach(function(model) {
let settings = model.settings;
let acls = settings.acls;
if (!acls)
model.settings.acls = acls = [];
acls.unshift({
accessType: '*',
principalType: 'ROLE',
principalId: 'root',
permission: 'ALLOW'
});
acls.push({
accessType: '*',
principalType: 'ROLE',
principalId: '$everyone',
permission: 'DENY'
});
if (settings.validateUpsert === undefined)
settings.validateUpsert = true;
});
app.enableAuth();
var router = app.loopback.Router();
router.get('/status', app.loopback.status());
app.use(router);
/*
let ds = app.dataSources.auth;
//ds.automigrate(function() {
ds.autoupdate(function() {
console.log('Tables migrated!');
});
*/
};