From a49aa70bd87be7b6e10fdfcb4b567a2918ecd706 Mon Sep 17 00:00:00 2001 From: wibus-wee <1596355173@qq.com> Date: Thu, 4 Aug 2022 20:38:54 +0800 Subject: [PATCH] perf(post): check password in query --- src/modules/comment/comment.service.ts | 2 +- src/modules/post/post.controller.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/comment/comment.service.ts b/src/modules/comment/comment.service.ts index 6a4c4de39..3d8d6680b 100644 --- a/src/modules/comment/comment.service.ts +++ b/src/modules/comment/comment.service.ts @@ -179,7 +179,7 @@ export class CommentService { { page, // 当前页 limit: size, // 每页显示条数 - select: isMaster ? "+ip +agent -children" : "", + select: "+ip +agent -children", // 查询字段 sort: { created: -1 }, // 排序 populate: [ // 关联查询 diff --git a/src/modules/post/post.controller.ts b/src/modules/post/post.controller.ts index caaeabf87..fbc542a25 100644 --- a/src/modules/post/post.controller.ts +++ b/src/modules/post/post.controller.ts @@ -174,7 +174,7 @@ export class PostController { async getByCategoryAndSlug( @Param() params: CategoryAndSlugDto, @IsMaster() isMaster: boolean, - @Cookies("password") password: any + @Query("password") password: any ) { const { category, slug } = params; const categoryDocument = await this.postService.getCategoryBySlug(category); @@ -199,7 +199,12 @@ export class PostController { // 将text, summary改为"内容已被隐藏" postDocument.text = "内容已被隐藏,请输入密码"; postDocument.summary = "内容已被隐藏,请输入密码"; + + } else { + postDocument.password = null; } + } else { + postDocument.password = null; } return postDocument; })