From 6f1a6c8fc858b99f3cfa2bda60707b1a959b827b Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 5 Jan 2026 17:20:58 +0800 Subject: [PATCH] core: domain_permission: support array as dict (close #1114) --- packages/hydrooj/src/handler/domain.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/hydrooj/src/handler/domain.ts b/packages/hydrooj/src/handler/domain.ts index 83b08e483..4f8ace852 100644 --- a/packages/hydrooj/src/handler/domain.ts +++ b/packages/hydrooj/src/handler/domain.ts @@ -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); }