From d0e4507d3b446062a4ae0eff0cfef6b76805bd40 Mon Sep 17 00:00:00 2001 From: HeeDragoN1123 Date: Tue, 17 Oct 2023 12:32:01 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[=EC=9E=91=EC=97=85=EC=A4=91]=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=EC=8B=9C=20user=EA=B0=92=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=EA=B0=80=EC=95=84=EB=8B=88=EB=9D=BC=20userId=EA=B0=92?= =?UTF-8?q?=EB=A7=8C=20=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth/auth.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index b9e9df7..7ebc8fb 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -53,6 +53,7 @@ export class AuthService { // res.header('Authorization', `Bearer ${accessToken}`); // res.header('RefreshToken', refreshToken); + //TODO : user값 대신 userId값만 넘어가게 수정해야함 () return { accessToken, refreshToken, user }; //리턴값 } From 44025ad4be54e5576882f6e5091c87c7e0c7e4e2 Mon Sep 17 00:00:00 2001 From: HeeDragoN1123 Date: Tue, 17 Oct 2023 12:39:19 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[=EC=99=84=EB=A3=8C]=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=EC=8B=9C=20user=EA=B0=92=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EB=8C=80=EC=8B=A0=20userId=EA=B0=92=EB=A7=8C=20=ED=94=84?= =?UTF-8?q?=EB=A1=A0=ED=8A=B8=EC=97=90=20=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth/auth.controller.ts | 4 ++-- src/auth/auth.service.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index a118c1d..b95c7bf 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -49,7 +49,7 @@ export class AuthController { @Req() req: Request, @Res({ passthrough: true }) res: Response // Response 객체 주입 ): Promise { - const { accessToken, refreshToken, user } = await this.authService.login({ + const { accessToken, refreshToken, userId } = await this.authService.login({ email, password, res, @@ -65,7 +65,7 @@ export class AuthController { // 리프레시 토큰을 HTTP 응답 헤더에 추가 res.header('refreshToken', refreshToken); - res.status(200).json({ user }); // 클라이언트에게 JSON 응답을 보냄 + res.status(200).json({ userId }); // 클라이언트에게 JSON 응답을 보냄 //res.cookie('refreshToken', refreshToken, { httpOnly: true, secure: false }); diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 7ebc8fb..30e57b1 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -22,7 +22,8 @@ export class AuthService { // 리팩토링 시 res 빼도 작동하는지 테스트 accessToken: string; refreshToken: string; - user: User; // User 정보를 반환하기 위한 타입 + //user: User; // User 정보를 반환하기 위한 타입 + userId: number; // userId만 반환 }> { // 1. 이메일이 일치하는 유저를 DB에서 찾기 const user = await this.usersService.findByEmail({ email }); @@ -54,7 +55,7 @@ export class AuthService { // res.header('RefreshToken', refreshToken); //TODO : user값 대신 userId값만 넘어가게 수정해야함 () - return { accessToken, refreshToken, user }; //리턴값 + return { accessToken, refreshToken, userId: user.userId }; //리턴값 } getAccessToken({ user, res }): string { From 2edbdc2fbb7391f956a102055c5b5f34bbd91316 Mon Sep 17 00:00:00 2001 From: HeeDragoN1123 Date: Tue, 17 Oct 2023 13:14:19 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20=EC=86=8C=EC=85=9C?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20userId=EA=B0=92=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80(=ED=99=95=EC=9D=B8=ED=95=84=EC=9A=94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth/auth.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 30e57b1..5488420 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -137,6 +137,6 @@ export class AuthService { // 리다이렉션 res.redirect('http://127.0.0.1:5500'); // 메인페이지 url 을 입력해야합니다. - return { accessToken, refreshToken }; + return { accessToken, refreshToken, userId: user.userId }; } } From b975c1ed0b33c0b1f7a708a18696dbe04298db07 Mon Sep 17 00:00:00 2001 From: HeeDragoN1123 Date: Tue, 17 Oct 2023 14:20:16 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20dto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth/auth.service.ts | 1 - src/users/dto/create-user.dto.ts | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 5488420..9d7892e 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -8,7 +8,6 @@ import { JwtService } from '@nestjs/jwt'; import * as bcrypt from 'bcrypt'; //import { IAuthServiceLogin } from './interface/auth-service.interface'; import { UsersService } from 'src/users/users.service'; -import { User } from '@prisma/client'; @Injectable() export class AuthService { diff --git a/src/users/dto/create-user.dto.ts b/src/users/dto/create-user.dto.ts index 30da43a..350c9c8 100644 --- a/src/users/dto/create-user.dto.ts +++ b/src/users/dto/create-user.dto.ts @@ -101,6 +101,7 @@ export class CreateUserDto { /* @IsOptional() */ @IsString() + @IsOptional() @ApiProperty({ description: 'profileImg', example: '프로필이미지 url', @@ -108,6 +109,7 @@ export class CreateUserDto { profileImg?: string; @IsString() + @IsOptional() @ApiProperty({ description: 'refreshToken', example: 'refreshToken',