Put providers

This commit is contained in:
cyril lopez 2018-01-22 10:23:04 +01:00
parent 9b1347d092
commit e425125f82
2 changed files with 26 additions and 1 deletions

View File

@ -96,7 +96,6 @@
"policies": [] "policies": []
} }
}, },
{ {
"method": "GET", "method": "GET",
"path": "/providers", "path": "/providers",
@ -106,6 +105,15 @@
} }
}, },
{
"method": "PUT",
"path": "/providers",
"handler": "UsersPermissions.updateProviders",
"config": {
"policies": []
}
},
{ {
"method": "POST", "method": "POST",

View File

@ -207,5 +207,22 @@ module.exports = {
getProviders: async (ctx) => { getProviders: async (ctx) => {
ctx.send(strapi.plugins['users-permissions'].config.grant); ctx.send(strapi.plugins['users-permissions'].config.grant);
},
updateProviders: async (ctx) => {
if (_.isEmpty(ctx.request.body)) {
return ctx.badRequest(null, [{ messages: [{ id: 'Cannot be empty' }] }]);
}
strapi.reload.isWatching = false;
fs.writeFileSync(path.join(strapi.config.appPath, 'plugins', 'users-permissions', 'config', 'grant.json'), JSON.stringify({
grant: ctx.request.body
}, null, 2), 'utf8');
ctx.send({ ok: true });
strapi.reload();
} }
}; };