mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 01:38:19 +08:00
core: domain_permission: support array as dict (close #1114)
This commit is contained in:
1 file changed
+4
-4
@@ -218,11 +218,11 @@ class DomainPermissionHandler extends ManageHandler {
|
||||
@requireSudo
|
||||
async post({ domainId }) {
|
||||
const roles = {};
|
||||
for (const role in this.request.body) {
|
||||
for (const [role, list] of Object.entries(this.request.body)) {
|
||||
if (role === 'root') continue; // root role is not editable
|
||||
const perms = this.request.body[role] instanceof Array
|
||||
? this.request.body[role]
|
||||
: [this.request.body[role]];
|
||||
const perms = Array.isArray(list) ? list
|
||||
: (typeof list === 'object' && list)
|
||||
? Object.values(list) : [list];
|
||||
roles[role] = 0n;
|
||||
for (const r of perms) roles[role] |= 1n << BigInt(r);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user