core: do not allow updating domain owner's permission

This commit is contained in:
undefined committed 2023-05-01 00:58:39 +08:00
1 parent a4100812c5
commit 2f2ef471f7
1 file changed
+3 -1
+3 -1
View File
@@ -3,7 +3,7 @@ import { Dictionary } from 'lodash';
import moment from 'moment-timezone'; import moment from 'moment-timezone';
import { Context } from '../context'; import { Context } from '../context';
import { import {
CannotDeleteSystemDomainError, DomainJoinAlreadyMemberError, DomainJoinForbiddenError, CannotDeleteSystemDomainError, DomainJoinAlreadyMemberError, DomainJoinForbiddenError, ForbiddenError,
InvalidJoinInvitationCodeError, OnlyOwnerCanDeleteDomainError, PermissionError, RoleAlreadyExistError, ValidationError, InvalidJoinInvitationCodeError, OnlyOwnerCanDeleteDomainError, PermissionError, RoleAlreadyExistError, ValidationError,
} from '../error'; } from '../error';
import type { DomainDoc } from '../interface'; import type { DomainDoc } from '../interface';
@@ -162,6 +162,7 @@ class DomainUserHandler extends ManageHandler {
@post('uid', Types.Int) @post('uid', Types.Int)
@post('role', Types.Role) @post('role', Types.Role)
async postSetUser(domainId: string, uid: number, role: string) { async postSetUser(domainId: string, uid: number, role: string) {
if (uid === this.domain.owner) throw new ForbiddenError();
await Promise.all([ await Promise.all([
domain.setUserRole(domainId, uid, role), domain.setUserRole(domainId, uid, role),
oplog.log(this, 'domain.setRole', { uid, role }), oplog.log(this, 'domain.setRole', { uid, role }),
@@ -173,6 +174,7 @@ class DomainUserHandler extends ManageHandler {
@param('uid', Types.NumericArray) @param('uid', Types.NumericArray)
@param('role', Types.Role) @param('role', Types.Role)
async postSetUsers(domainId: string, uid: number[], role: string) { async postSetUsers(domainId: string, uid: number[], role: string) {
if (uid.includes(this.domain.owner)) throw new ForbiddenError();
await Promise.all([ await Promise.all([
domain.setUserRole(domainId, uid, role), domain.setUserRole(domainId, uid, role),
oplog.log(this, 'domain.setRole', { uid, role }), oplog.log(this, 'domain.setRole', { uid, role }),