Skip to content

Commit 6f1a6c8

Browse files
committed
core: domain_permission: support array as dict (close #1114)
1 parent bea8e47 commit 6f1a6c8

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/hydrooj/src/handler/domain.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ class DomainPermissionHandler extends ManageHandler {
218218
@requireSudo
219219
async post({ domainId }) {
220220
const roles = {};
221-
for (const role in this.request.body) {
221+
for (const [role, list] of Object.entries(this.request.body)) {
222222
if (role === 'root') continue; // root role is not editable
223-
const perms = this.request.body[role] instanceof Array
224-
? this.request.body[role]
225-
: [this.request.body[role]];
223+
const perms = Array.isArray(list) ? list
224+
: (typeof list === 'object' && list)
225+
? Object.values(list) : [list];
226226
roles[role] = 0n;
227227
for (const r of perms) roles[role] |= 1n << BigInt(r);
228228
}

0 commit comments

Comments
 (0)