Skip to content

Commit

Permalink
perf(post): check password in query
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee committed Aug 4, 2022
1 parent a7800c4 commit a49aa70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/modules/comment/comment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class CommentService {
{
page, // 当前页
limit: size, // 每页显示条数
select: isMaster ? "+ip +agent -children" : "",
select: "+ip +agent -children", // 查询字段
sort: { created: -1 }, // 排序
populate: [
// 关联查询
Expand Down
7 changes: 6 additions & 1 deletion src/modules/post/post.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -199,7 +199,12 @@ export class PostController {
// 将text, summary改为"内容已被隐藏"
postDocument.text = "内容已被隐藏,请输入密码";
postDocument.summary = "内容已被隐藏,请输入密码";

} else {
postDocument.password = null;
}
} else {
postDocument.password = null;
}
return postDocument;
})
Expand Down

0 comments on commit a49aa70

Please sign in to comment.