mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +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 => {
|
||||
return {
|
||||
initialize: function(cb) {
|
||||
strapi.app.use(async (ctx, next) => {
|
||||
await next();
|
||||
_.forEach(strapi.config.routes, value => {
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
"dependencies": {
|
||||
"bcryptjs": "^2.4.3",
|
||||
"jsonwebtoken": "^8.1.0",
|
||||
"path-to-regexp": "^2.1.0",
|
||||
"sendmail": "^1.2.0",
|
||||
"strapi-helper-plugin": "3.0.0-alpha.6.7"
|
||||
},
|
||||
@ -62,4 +63,4 @@
|
||||
"rimraf": "^2.6.2",
|
||||
"webpack": "^3.8.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user