first commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
verifyPermission: function (role, roleName) {
|
||||
return function (req, res, next) {
|
||||
const permissions = req.session.permissions || [];
|
||||
|
||||
const isAllowedPermission = permissions.find(
|
||||
(permission) => `/${roleName}${permission}` === req.originalUrl,
|
||||
);
|
||||
|
||||
if (isAllowedPermission) {
|
||||
return next();
|
||||
} else {
|
||||
return res.redirect(`/${roleName}/dashboard`);
|
||||
}
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user