This commit is contained in:
ryanwong
2022-02-06 22:15:10 -05:00
parent 46625dd6cd
commit a07577bffa
145 changed files with 12008 additions and 0 deletions
+17
View File
@@ -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`);
}
};
},
};