Revert "[medusa-interfaces] : Adds decorator functionality to BaseService (#39)" (#41)

This reverts commit 9c76754e79.
This commit is contained in:
Sebastian Rindom
2020-04-30 21:16:09 +02:00
committed by GitHub
parent 9c76754e79
commit 2273cc519a
15 changed files with 654 additions and 112 deletions
@@ -0,0 +1,14 @@
// This middleware is injected to ensure authorization of requests
// Since this middleware uses the user object on the request, this should be
// injected after authentication in the core middleware, hence we name
// the middleware postAuth.
export default postAuth = () => {
return (err, req, res, next) => {
const permissionService = req.scope.resolve("permissionService")
if (permissionService.hasPermission(req.user, req.method, req.path)) {
next()
} else {
res.status(422)
}
}
}