feat: allow multiple privileges to be defined for a given admin socket call

v1.18.x
Julian Lam 4 years ago
parent f55dddb2be
commit 3aa5beb832

@ -41,8 +41,9 @@ SocketAdmin.before = async function (socket, method) {
}
// Check admin privileges mapping (if not in mapping, deny access)
const privilege = privileges.admin.socketMap[method];
if (privilege && await privileges.admin.can(privilege, socket.uid)) {
const privilegeSet = privileges.admin.socketMap[method].split(';');
const hasPrivilege = (await Promise.all(privilegeSet.map(async privilege => privileges.admin.can(privilege, socket.uid)))).some(Boolean);
if (privilegeSet.length && hasPrivilege) {
return;
}

Loading…
Cancel
Save