mirror of
https://github.com/strapi/strapi.git
synced 2025-11-04 20:07:19 +00:00
Inject authentication policy
This commit is contained in:
parent
a2c8e212fc
commit
9a801e4ac1
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = async (ctx, next) => {
|
||||||
|
const config = strapi.plugins['users-permissions'].config;
|
||||||
|
|
||||||
|
await next();
|
||||||
|
};
|
||||||
@ -1,10 +1,21 @@
|
|||||||
|
const pathToRegexp = require('path-to-regexp');
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
module.exports = strapi => {
|
module.exports = strapi => {
|
||||||
return {
|
return {
|
||||||
initialize: function(cb) {
|
initialize: function(cb) {
|
||||||
strapi.app.use(async (ctx, next) => {
|
_.forEach(strapi.config.routes, value => {
|
||||||
await next();
|
value.config.policies.unshift('plugins.users-permissions.isAuthenticated');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (strapi.plugins) {
|
||||||
|
_.forEach(strapi.plugins, (plugin, name) => {
|
||||||
|
_.forEach(plugin.config.routes, value => {
|
||||||
|
value.config.policies.unshift('plugins.users-permissions.isAuthenticated');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"jsonwebtoken": "^8.1.0",
|
"jsonwebtoken": "^8.1.0",
|
||||||
|
"path-to-regexp": "^2.1.0",
|
||||||
"sendmail": "^1.2.0",
|
"sendmail": "^1.2.0",
|
||||||
"strapi-helper-plugin": "3.0.0-alpha.6.7"
|
"strapi-helper-plugin": "3.0.0-alpha.6.7"
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user