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

41 lines
967 B
JavaScript

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!');
});
*/
};