Merge pull request #588 from strapi/fix/role

Populate type field when creating a role #553
This commit is contained in:
Jim LAURIE 2018-02-06 17:58:37 +01:00 committed by GitHub
commit 12723d1f4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,11 @@ module.exports = {
return new Error('This feature requires to install the Content Manager plugin');
}
const role = await strapi.query('role', 'users-permissions').create(_.omit(params, ['users', 'permissions', 'type']));
if (!params.type) {
params.type = _.snakeCase(_.deburr(_.toLower(params.name)));
}
const role = await strapi.query('role', 'users-permissions').create(_.omit(params, ['users', 'permissions']));
const arrayOfPromises = Object.keys(params.permissions).reduce((acc, type) => {
Object.keys(params.permissions[type].controllers).forEach(controller => {