Guh
This commit is contained in:
parent
4ce8634b66
commit
7d64d0e78a
6
index.js
6
index.js
|
@ -44,15 +44,15 @@ global.comparePassword = async function(password, hash) {
|
|||
return await bcrypt.compare(password, hash);
|
||||
};
|
||||
|
||||
global.checkACL = function(req, res, next, perm) {
|
||||
global.checkACL = function(req,, perm) {
|
||||
if (!req.session.user) {
|
||||
return res.status(401).render('error', { error: 'You must be logged in to access this resource.' });
|
||||
}
|
||||
const perms = req.session.user.perms ? JSON.parse(req.session.user.perms) : [];
|
||||
if (perms.includes('*') || perms.includes(perm)) {
|
||||
return next();
|
||||
return true;
|
||||
}
|
||||
return res.status(403).render('error', { error: 'You do not have permission to access this resource.', button: {text: "Go Back", action:"back"} });
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue