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();
|
|
|
|
|
2019-06-06 11:59:11 +00:00
|
|
|
// eslint-disable-next-line new-cap
|
2018-12-27 11:54:16 +00:00
|
|
|
let router = app.loopback.Router();
|
2017-10-13 14:22:45 +00:00
|
|
|
router.get('/status', app.loopback.status());
|
|
|
|
app.use(router);
|
2019-06-06 11:59:11 +00:00
|
|
|
|
2017-10-13 14:22:45 +00:00
|
|
|
/*
|
|
|
|
let ds = app.dataSources.auth;
|
|
|
|
//ds.automigrate(function() {
|
|
|
|
ds.autoupdate(function() {
|
|
|
|
console.log('Tables migrated!');
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
};
|