server: fix get user error

pull/60/head
fantasticit 2022-05-26 00:36:52 +08:00
parent cfadcf22a0
commit 9c63c09f4d
1 changed files with 3 additions and 0 deletions

View File

@ -47,6 +47,9 @@ export class DocumentAuthorityGuard implements CanActivate {
throw new HttpException('您不是该文档的创建者,无法操作', HttpStatus.FORBIDDEN);
}
} else if (needAuth) {
if (!user) {
throw new HttpException('请登录后使用', HttpStatus.UNAUTHORIZED);
}
const authority = await this.documentService.getDocumentAuthority(documentId, user.id);
if (!authority || !authority[needAuth]) {
throw new HttpException('您无权操作此文档', HttpStatus.FORBIDDEN);