Execute controller action out of authorization try

This commit is contained in:
Jim Laurie 2018-01-09 13:53:52 +01:00
parent 6a59946f71
commit ff46faf306
9 changed files with 18 additions and 17 deletions

View File

@ -46,4 +46,4 @@
"npm": ">= 3.0.0"
},
"license": "MIT"
}
}

View File

@ -55,4 +55,4 @@
"npm": ">= 5.3.0"
},
"license": "MIT"
}
}

View File

@ -46,4 +46,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
}
}

View File

@ -48,4 +48,4 @@
"react-select": "^1.0.0-rc.5",
"strapi-helper-plugin": "3.0.0-alpha.7.3"
}
}
}

View File

@ -48,4 +48,4 @@
"npm": ">= 3.0.0"
},
"license": "MIT"
}
}

View File

@ -46,4 +46,4 @@
"npm": ">= 3.0.0"
},
"license": "MIT"
}
}

View File

@ -45,4 +45,4 @@
"npm": ">= 3.0.0"
},
"license": "MIT"
}
}

View File

@ -10,18 +10,19 @@ module.exports = async (ctx, next) => {
ctx.state.user = await strapi.plugins['users-permissions'].services.user.fetch(_.pick(tokenUser, ['_id', 'id']));
if (!ctx.state.user) {
ctx.unauthorized('This user doesn\'t exit.');
}
role = ctx.state.user.role;
if (role.toString() === '0') {
return await next();
}
} catch (err) {
return ctx.unauthorized(err);
}
if (!ctx.state.user) {
ctx.unauthorized('This user doesn\'t exit.');
}
role = ctx.state.user.role;
if (role.toString() === '0') {
return await next();
}
}
const permission = _.get(strapi.plugins['users-permissions'].config, ['roles', role.toString(), 'permissions', route.plugin || 'application', 'controllers', route.controller, route.action]);

View File

@ -48,4 +48,4 @@
"npm": ">= 3.0.0"
},
"license": "MIT"
}
}