Fix feedback PR

This commit is contained in:
cyril lopez 2017-12-08 14:40:42 +01:00
parent b4cae064d5
commit 3da6faac05
2 changed files with 1 additions and 9 deletions

View File

@ -18,9 +18,6 @@ module.exports = async (ctx, next) => {
} }
const permission = _.get(strapi.plugins['users-permissions'].config, ['roles', role.toString(), 'permissions', route.plugin || 'application', 'controllers', route.controller, route.action]); const permission = _.get(strapi.plugins['users-permissions'].config, ['roles', role.toString(), 'permissions', route.plugin || 'application', 'controllers', route.controller, route.action]);
console.log(permission);
console.log('---')
console.log(role);
if (!permission) { if (!permission) {
return await next(); return await next();

View File

@ -14,12 +14,7 @@ const _ = require('lodash');
module.exports = { module.exports = {
createRole: (role) => { createRole: (role) => {
const appRoles = strapi.plugins['users-permissions'].config.roles; const appRoles = strapi.plugins['users-permissions'].config.roles;
const highestId = _.last(Object.keys(appRoles).reduce((acc, key) => { const highestId = Math.max(...Object.keys(appRoles).map(Number)) + 1;
acc.push(_.toNumber(key));
return acc;
}, []).sort()) + 1;
const newRole = _.pick(role, ['name', 'description', 'permissions']); const newRole = _.pick(role, ['name', 'description', 'permissions']);
_.set(appRoles, highestId.toString(), newRole); _.set(appRoles, highestId.toString(), newRole);