From d5e96c24eebea42578b7bd7bcf3a713edd2f9ed8 Mon Sep 17 00:00:00 2001 From: msjang4 Date: Fri, 1 Dec 2023 22:26:37 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85?= =?UTF-8?q?=20=ED=94=84=EB=A1=9C=ED=95=84=20presignedURL=20=EB=B0=9C?= =?UTF-8?q?=EA=B8=89=20=EC=9A=94=EC=B2=AD=20=EC=8A=A4=ED=82=A4=EB=A7=88?= =?UTF-8?q?=EC=97=90=20=EC=86=8C=EC=85=9C=20accessToken=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80-conflict=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 5tarry --- server/src/auth/auth.controller.ts | 12 +++++++++--- server/src/auth/auth.service.ts | 8 ++++++-- ...signup-profile-presigned-url-request.dto.ts | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 server/src/presigned-url/dto/signup-profile-presigned-url-request.dto.ts diff --git a/server/src/auth/auth.controller.ts b/server/src/auth/auth.controller.ts index 18ad507..68b16ec 100644 --- a/server/src/auth/auth.controller.ts +++ b/server/src/auth/auth.controller.ts @@ -8,8 +8,8 @@ import { LoginFailException } from 'src/exceptions/login-fail.exception'; import { InvalidRefreshTokenException } from 'src/exceptions/invalid-refresh-token.exception'; import { ProfileUploadRequiredException } from 'src/exceptions/profile-upload-required-exception'; import { PresignedUrlResponseDto } from 'src/presigned-url/dto/presigned-url-response.dto'; -import { ProfilePresignedUrlRequestDto } from 'src/presigned-url/dto/profile-presigned-url-request.dto'; import { PresignedUrlService } from 'src/presigned-url/presigned-url.service'; +import { SignupProfilePresignedUrlRequestDto } from 'src/presigned-url/dto/signup-profile-presigned-url-request.dto'; import { AuthService } from './auth.service'; import { SignupRequestDto } from './dto/signup-request.dto'; import { SignupResponseDto } from './dto/signup-response.dto'; @@ -75,7 +75,13 @@ export class AuthController { '프로필 이미지를 업로드하는 url 발급 성공', PresignedUrlResponseDto, ) - putProfilePresignedUrl(@Query() query: ProfilePresignedUrlRequestDto) { - return this.presignedUrlService.putProfilePresignedUrl(query); + async putProfilePresignedUrl( + @Query() query: SignupProfilePresignedUrlRequestDto, + ) { + await this.authService.checkUserConflict(query.uuid); + return this.presignedUrlService.putProfilePresignedUrl( + query.uuid, + query.profileExtension, + ); } } diff --git a/server/src/auth/auth.service.ts b/server/src/auth/auth.service.ts index 89ba7e5..344b65f 100644 --- a/server/src/auth/auth.service.ts +++ b/server/src/auth/auth.service.ts @@ -24,11 +24,15 @@ export class AuthService { private jwtService: JwtService, ) {} - async create(signupRequestDto: SignupRequestDto): Promise { - const { uuid, profileImageExtension } = signupRequestDto; + async checkUserConflict(uuid: string): Promise { if (await this.UserModel.findOne({ uuid })) { throw new UserConflictException(); } + } + + async create(signupRequestDto: SignupRequestDto): Promise { + const { uuid, profileImageExtension } = signupRequestDto; + await this.checkUserConflict(uuid); if ( profileImageExtension && !(await checkUpload( diff --git a/server/src/presigned-url/dto/signup-profile-presigned-url-request.dto.ts b/server/src/presigned-url/dto/signup-profile-presigned-url-request.dto.ts new file mode 100644 index 0000000..ec387dd --- /dev/null +++ b/server/src/presigned-url/dto/signup-profile-presigned-url-request.dto.ts @@ -0,0 +1,18 @@ +import { IsNotEmpty, IsUUID } from 'class-validator'; +import { ProfilePresignedUrlRequestDto } from './profile-presigned-url-request.dto'; + +export class SignupProfilePresignedUrlRequestDto extends ProfilePresignedUrlRequestDto { + /** + * 유저 ID + * @example '550e8400-e29b-41d4-a716-446655440000' + */ + @IsUUID() + uuid: string; + + /** + * 소셜 accessToken + * @example '1/fFAGRNJru1FTz70BzhT3Zg' + */ + @IsNotEmpty() + accessToken: string; +}