2018-01-12 15:20:13 +01:00
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Module dependencies
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Public node modules.
|
|
|
|
|
const _ = require('lodash');
|
|
|
|
|
const Grant = require('grant-koa');
|
|
|
|
|
|
|
|
|
|
module.exports = strapi => {
|
|
|
|
|
return {
|
|
|
|
|
beforeInitialize: function() {
|
|
|
|
|
strapi.config.middleware.load.after.push('provider');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
initialize: function(cb) {
|
|
|
|
|
_.defaultsDeep(strapi.plugins['users-permissions'].config.grant, {
|
|
|
|
|
server: {
|
|
|
|
|
protocol: 'http',
|
|
|
|
|
host: 'localhost:1337'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const grant = new Grant(strapi.plugins['users-permissions'].config.grant);
|
|
|
|
|
|
2018-01-23 09:30:25 +01:00
|
|
|
|
strapi.app.use(strapi.koaMiddlewares.compose(grant.middleware));
|
2018-01-12 15:20:13 +01:00
|
|
|
|
|
|
|
|
|
cb();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|