mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 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
|
@requireSudo
|
||||||
async post({ domainId }) {
|
async post({ domainId }) {
|
||||||
const roles = {};
|
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
|
if (role === 'root') continue; // root role is not editable
|
||||||
const perms = this.request.body[role] instanceof Array
|
const perms = Array.isArray(list) ? list
|
||||||
? this.request.body[role]
|
: (typeof list === 'object' && list)
|
||||||
: [this.request.body[role]];
|
? Object.values(list) : [list];
|
||||||
roles[role] = 0n;
|
roles[role] = 0n;
|
||||||
for (const r of perms) roles[role] |= 1n << BigInt(r);
|
for (const r of perms) roles[role] |= 1n << BigInt(r);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user