Skip to content

Conversation

@KOO612
Copy link
Collaborator

@KOO612 KOO612 commented Dec 29, 2025

개요

로그인 및 회원가입 기능을 추가하고, 회원가입에 대한 기본 테스트 코드를 작성한 풀 리퀘스트입니다.

주요 변경 사항

  • JWT를 활용한 로그인 인증 로직을 구현했습니다.
  • bcrypt를 사용해 회원가입 시 비밀번호를 해싱하여 저장하도록 처리했습니다.
  • 회원가입 기능의 기본 동작을 검증하는 테스트 코드를 추가했습니다.

기술적 구현 내용

  • 로그인 성공 시 JWT 액세스 토큰을 발급하고, 이후 보호된 엔드포인트 접근 시 해당 토큰으로 인증할 수 있도록 구성했습니다.
  • 회원가입 시 평문 비밀번호 대신 bcrypt로 해싱한 값만 데이터베이스에 저장되도록 구현했습니다.

추후 계획

  • @nestjs/throttler를 도입하여 로그인 시도 빈도에 대한 레이트 리밋을 추가할 예정입니다.
  • 과도한 로그인 시도로 인한 브루트 포스 공격을 방지하기 위해 설정 값을 조정하고, 관련 예외 처리 및 에러 응답 형식을 정리할 계획입니다.

@KOO612 KOO612 requested a review from f-lab-namu December 29, 2025 06:06
@KOO612 KOO612 self-assigned this Dec 29, 2025
inject: [ConfigService],
useFactory: async (config: ConfigService) => ({
secret: config.get<string>('JWT_SECRET'),
signOptions: { expiresIn: '1d' },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[tip / not issue] 1d 같은 부분은 설정으로 따로 빼면 좋습니다


@Get(':id')
findOne(@Param('id', ParseIntPipe) id: number) {
return this.usersService.findOne(+id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

암시적 변환이 아닌 명시적 변환 코드가 좋습니다

expect(result.password).toBe(hashedPassword);
});

it('email 중복 체크', async () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트 코드 naming 을 할때에는 기대 결과와 조건 실제 상태등이 드러나는 이름으로 지으면 좋습니다.
키워드로 "테스트 코드 네이밍" 등을 검색해서 학습하신 후 본인이 선호되는 스타일로 이름을 다시 지어주세요~

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분 리뷰가 반영이 되지 않았습니다


jest.mock('bcrypt');

describe('UsersService', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트 코드 있어서 너무 좋습니다! 👍

async create(createUserDto: CreateUserDto): Promise<User> {
const existingUser = await this.findByEmail(createUserDto.email);
if (existingUser) {
throw new ConflictException('이미 존재하는 이메일입니다.');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다양한 status code 를 잘 활용하시는 부분이 좋습니다! 👍

@f-lab-namu
Copy link

https://docs.nestjs.com/pipes#providing-defaults

이 코드 예시를 보면 ParseIntPipe 를 적용하면 알아서 Number 로 되기 때문에 Number 생성자를 중복으로 쓰지 않아도 되지 않나요?

@KOO612 KOO612 closed this Jan 5, 2026
@KOO612 KOO612 reopened this Jan 5, 2026
@KOO612 KOO612 merged commit 3cbf789 into main Jan 5, 2026
2 checks passed
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 5, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots

See analysis details on SonarQube Cloud

@KOO612 KOO612 deleted the feature/3 branch January 5, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants