2018-01-12 15:20:13 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Public node modules.
|
2017-11-27 10:59:24 +01:00
|
|
|
const _ = require('lodash');
|
|
|
|
|
2017-11-24 15:15:02 +01:00
|
|
|
module.exports = strapi => {
|
|
|
|
return {
|
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')) {
|
2019-04-05 16:11:09 +02:00
|
|
|
value.config.policies.unshift(
|
|
|
|
'plugins.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')) {
|
2019-04-05 16:11:09 +02:00
|
|
|
value.config.policies.unshift(
|
|
|
|
'plugins.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')) {
|
2019-04-05 16:11:09 +02:00
|
|
|
value.config.policies.unshift(
|
|
|
|
'plugins.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
|
|
|
},
|
2017-11-24 15:15:02 +01:00
|
|
|
};
|
|
|
|
};
|