2018-01-12 15:20:13 +01:00
|
|
|
'use strict';
|
|
|
|
|
2017-11-27 10:59:24 +01:00
|
|
|
const _ = require('lodash');
|
|
|
|
|
2021-07-29 16:39:26 +02:00
|
|
|
module.exports = {
|
|
|
|
defaults: { 'users-permissions': { enabled: true } },
|
|
|
|
load: {
|
2019-06-08 18:50:07 +02:00
|
|
|
beforeInitialize() {
|
2017-11-28 10:02:30 +01:00
|
|
|
strapi.config.middleware.load.before.unshift('users-permissions');
|
|
|
|
},
|
|
|
|
|
2019-06-08 18:50:07 +02:00
|
|
|
initialize() {
|
2018-07-30 10:53:44 +02:00
|
|
|
_.forEach(strapi.admin.config.routes, value => {
|
|
|
|
if (_.get(value.config, 'policies')) {
|
2021-08-06 18:09:49 +02:00
|
|
|
value.config.policies.unshift('plugin::users-permissions.permissions');
|
2018-07-30 10:53:44 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-11-27 10:59:24 +01:00
|
|
|
_.forEach(strapi.config.routes, value => {
|
2017-12-08 11:21:51 +01:00
|
|
|
if (_.get(value.config, 'policies')) {
|
2021-08-06 18:09:49 +02:00
|
|
|
value.config.policies.unshift('plugin::users-permissions.permissions');
|
2017-12-08 11:21:51 +01:00
|
|
|
}
|
2017-11-24 15:15:02 +01:00
|
|
|
});
|
|
|
|
|
2017-11-27 10:59:24 +01:00
|
|
|
if (strapi.plugins) {
|
2019-04-05 16:11:09 +02:00
|
|
|
_.forEach(strapi.plugins, plugin => {
|
2017-11-27 10:59:24 +01:00
|
|
|
_.forEach(plugin.config.routes, value => {
|
2017-12-08 11:21:51 +01:00
|
|
|
if (_.get(value.config, 'policies')) {
|
2021-08-06 18:09:49 +02:00
|
|
|
value.config.policies.unshift('plugin::users-permissions.permissions');
|
2017-12-08 11:21:51 +01:00
|
|
|
}
|
2017-11-27 10:59:24 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2019-04-05 16:11:09 +02:00
|
|
|
},
|
2021-07-29 16:39:26 +02:00
|
|
|
},
|
2017-11-24 15:15:02 +01:00
|
|
|
};
|