core&ui: fix defaultPriv edit (#444)

Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
pandaandundefined authored and GitHub committed 2022-10-18 11:45:00 +08:00
1 parent e964eec099
commit a230d1c7c3
5 files changed
+39 -38

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "4.1.0",
"version": "4.1.1",
"bin": "bin/hydrooj.js",
"main": "src/plugin-api",
"module": "src/plugin-api",
+4 -3
View File
@@ -286,10 +286,11 @@ class SystemUserPrivHandler extends SystemHandler {
}
@requireSudo
@param('uid', Types.Int, true)
@param('uid', Types.Int)
@param('priv', Types.UnsignedInt)
async post(domainId: string, uid: number, priv: number) {
if (typeof uid === 'number') {
@param('system', Types.Boolean, true)
async post(domainId: string, uid: number, priv: number, editSystem: boolean) {
if (!editSystem) {
const udoc = await user.getById(domainId, uid);
if (!udoc) throw new UserNotFoundError(uid);
if (udoc.priv === -1 || priv === -1 || priv === allPriv) throw new ForbiddenError('you can not edit user as SU in web.');