We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bea8e47 commit 6f1a6c8Copy full SHA for 6f1a6c8
1 file changed
packages/hydrooj/src/handler/domain.ts
@@ -218,11 +218,11 @@ class DomainPermissionHandler extends ManageHandler {
218
@requireSudo
219
async post({ domainId }) {
220
const roles = {};
221
- for (const role in this.request.body) {
+ for (const [role, list] of Object.entries(this.request.body)) {
222
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]];
+ const perms = Array.isArray(list) ? list
+ : (typeof list === 'object' && list)
+ ? Object.values(list) : [list];
226
roles[role] = 0n;
227
for (const r of perms) roles[role] |= 1n << BigInt(r);
228
}
0 commit comments