Skip to content

Commit

Permalink
feat : 회원가입 프로필 presignedURL 발급 요청 스키마에 소셜 accessToken 추가-conflict 예외처리
Browse files Browse the repository at this point in the history
Co-authored-by: 5tarry <hacherry05@naver.com>
  • Loading branch information
msjang4 and 5tarry committed Dec 1, 2023
1 parent 3976412 commit d5e96c2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
12 changes: 9 additions & 3 deletions server/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
);
}
}
8 changes: 6 additions & 2 deletions server/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ export class AuthService {
private jwtService: JwtService,
) {}

async create(signupRequestDto: SignupRequestDto): Promise<SignupResponseDto> {
const { uuid, profileImageExtension } = signupRequestDto;
async checkUserConflict(uuid: string): Promise<void> {
if (await this.UserModel.findOne({ uuid })) {
throw new UserConflictException();
}
}

async create(signupRequestDto: SignupRequestDto): Promise<SignupResponseDto> {
const { uuid, profileImageExtension } = signupRequestDto;
await this.checkUserConflict(uuid);
if (
profileImageExtension &&
!(await checkUpload(
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit d5e96c2

Please sign in to comment.