From 4b401f8886180516ee4b62b0f04b6584f8bb6291 Mon Sep 17 00:00:00 2001 From: wibus-wee <1596355173@qq.com> Date: Mon, 18 Jul 2022 16:52:54 +0800 Subject: [PATCH] fix(post): get password from cookie instead of body --- src/common/decorator/cookie.decorator.ts | 2 +- src/modules/post/post.controller.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/decorator/cookie.decorator.ts b/src/common/decorator/cookie.decorator.ts index 55c6b39cc..279fa20db 100644 --- a/src/common/decorator/cookie.decorator.ts +++ b/src/common/decorator/cookie.decorator.ts @@ -22,6 +22,6 @@ export const Cookies = createParamDecorator( cookieObj[key] = value; } ); - return cookieObj; + return data ? cookieObj[data] : cookieObj; }, ); \ No newline at end of file diff --git a/src/modules/post/post.controller.ts b/src/modules/post/post.controller.ts index d05a95bdb..f6f5af510 100644 --- a/src/modules/post/post.controller.ts +++ b/src/modules/post/post.controller.ts @@ -149,7 +149,7 @@ export class PostController { @Get("/:category/:slug") @ApiOperation({ summary: "根据分类名与自定义别名获取文章详情" }) - async getByCategoryAndSlug(@Param() params: CategoryAndSlugDto, @IsMaster() isMaster: boolean, @Cookies() password: any) { + async getByCategoryAndSlug(@Param() params: CategoryAndSlugDto, @IsMaster() isMaster: boolean, @Cookies("password") password: any) { const { category, slug } = params; const categoryDocument = await this.postService.getCategoryBySlug(category); console.log(password);