salix/loopback/server/boot/root.js

42 lines
1007 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();
// eslint-disable-next-line new-cap
let 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!');
});
*/
};