first commit

This commit is contained in:
ryanwong
2022-04-12 08:57:07 -04:00
commit 1bab399b38
446 changed files with 109788 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`);
}
};
},
};