diff --git a/packages/hydrooj/src/handler/domain.ts b/packages/hydrooj/src/handler/domain.ts index e5e62ce57..f2c25189c 100644 --- a/packages/hydrooj/src/handler/domain.ts +++ b/packages/hydrooj/src/handler/domain.ts @@ -5,7 +5,7 @@ import Schema from 'schemastery'; import type { Context } from '../context'; import { CannotDeleteSystemDomainError, DomainJoinAlreadyMemberError, DomainJoinForbiddenError, ForbiddenError, - InvalidJoinInvitationCodeError, OnlyOwnerCanDeleteDomainError, PermissionError, RoleAlreadyExistError, ValidationError, + InvalidJoinInvitationCodeError, NotFoundError, OnlyOwnerCanDeleteDomainError, PermissionError, RoleAlreadyExistError, ValidationError, } from '../error'; import type { DomainDoc } from '../interface'; import avatar from '../lib/avatar'; @@ -344,6 +344,7 @@ class DomainJoinHandler extends Handler { domain.get(target), domain.collUser.findOne({ domainId: target, uid: this.user._id }), ]); + if (!ddoc) throw new NotFoundError(target); const assignedRole = this.user.hasPriv(PRIV.PRIV_MANAGE_ALL_DOMAIN) ? 'root' : dudoc?.role || 'default';