Skip to content

Comments

feat: 카카오 로그인 시 성별·생년월일 기반 유저 정보 자동 생성#96

Open
annalee8595 wants to merge 8 commits intodevfrom
feat/auth-kakao-profile-init
Open

feat: 카카오 로그인 시 성별·생년월일 기반 유저 정보 자동 생성#96
annalee8595 wants to merge 8 commits intodevfrom
feat/auth-kakao-profile-init

Conversation

@annalee8595
Copy link
Contributor

@annalee8595 annalee8595 commented Feb 9, 2026

이슈 번호

close #95

주요 변경사항

  • 카카오 프로필 응답에 gender, birthday, birthyear 필드 처리 로직 추가
  • birthyear + birthday(MMDD)를 기반으로 birthdate(UTC) 생성 및 age 계산
  • 카카오 gender 값을 Sex(M/F) enum으로 매핑
  • 신규 유저 생성 시 birthdate / age / sex 자동 저장
  • 기존 유저 로그인 시, 값이 존재하는 경우에 한해 해당 필드 부분 업데이트
  • onboardingRequired 판단 로직은 기존 정책 유지

테스트 결과 (스크린샷)

스크린샷 2026-02-10 오전 3 57 47

참고 및 개선사항

  • .env의 KAKAO_CLIENT_ID 및 KAKAO_CLIENT_SECRET 값을 이음-TEST의 키 값으로 변경해야 (노션 참고)

Copilot AI review requested due to automatic review settings February 9, 2026 20:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

카카오 로그인 시 프로필 응답의 gender / birthyear / birthday를 활용해 Usersex / birthdate / age를 자동 생성·부분 갱신하려는 변경이며, 서버의 쿠키 파싱을 cookie-parser 미들웨어로 전환합니다.

Changes:

  • Kakao profile 응답에 성별/생년월일 필드를 파싱해 birthdate(UTC)age 계산, Sex 매핑 후 유저 생성/업데이트에 반영
  • /users/me 응답에서 birthDate 대신 age를 내려주도록 DTO/서비스/리포지토리 수정
  • main.ts의 수동 쿠키 파싱 로직 제거 후 cookie-parser 적용 및 관련 패키지 추가

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/modules/auth/services/kakao-auth.service.ts 카카오 프로필에서 birth/sex 정보를 파싱해 유저 upsert에 반영, 온보딩 판단 로직 일부 수정
src/modules/user/services/user/user.service.ts getMe 응답에서 birthDate 대신 age 반환하도록 변경
src/modules/user/repositories/user.repository.ts findProfileById 조회 필드를 birthdateage로 변경
src/modules/user/dtos/user-me-response.dto.ts /users/me 스키마에서 birthDate 제거 및 age 필드 추가
src/main.ts 수동 쿠키 파싱 제거, cookie-parser 미들웨어로 전환
package.json cookie-parser 및 타입 패키지 추가(추가로 cookie도 포함)
package-lock.json 의존성/버전 고정 및 cookie(-parser) 관련 락 업데이트
Comments suppressed due to low confidence (1)

src/modules/auth/services/kakao-auth.service.ts:340

  • PR 설명에 따르면 onboardingRequired 판단 로직은 기존 정책을 유지해야 하는데, 현재 isOnboardingRequired에서 기본 birthdate(DEFAULT_BIRTHDATE) 여부 체크가 제거되어 신규 유저가 생년월일 정보를 못 받았을 때도 온보딩이 필요하지 않은 것으로 처리됩니다. 기본값(1900-01-01/age default 등)이 남은 상태로 서비스 흐름을 타게 되므로, 기존처럼 birthdate(또는 age/sex 포함) 기반의 온보딩 필요 조건을 다시 포함시키거나 정책 변경이라면 명시적으로 반영해 주세요.
  private isOnboardingRequired(user: {
    introText: string;
    introVoiceUrl: string;
    profileImageUrl: string;
    code: string;
  }) {
    return (
      user.introText.trim() === '' ||
      user.introVoiceUrl === KakaoAuthService.DEFAULT_INTRO_VOICE_URL ||
      user.profileImageUrl === KakaoAuthService.DEFAULT_PROFILE_IMAGE_URL ||
      user.code === KakaoAuthService.DEFAULT_ADDRESS_CODE
    );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -19,8 +19,8 @@ export class UserMeResponseDto {
@ApiProperty({ example: 'F', enum: Sex })
gender: Sex;

Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

UserMeResponseDto에서 birthDate를 제거하고 age로 대체하면서 /users/me 응답 스키마가 깨지는 변경이 들어갔습니다. 현재 다른 DTO/로직에서는 여전히 birthDate를 사용하고 있어(예: 프로필 업데이트/온보딩) API 일관성이 깨집니다. 호환성을 위해 birthDate를 유지하고 age를 추가로 제공하거나, 버전업/마이그레이션 계획을 포함해 변경을 조정해 주세요.

Suggested change
@ApiProperty({
example: '1970-01-01',
description: '생년월일 (ISO 8601). 향후 age 필드로 대체 예정',
deprecated: true,
})
birthDate: string;

Copilot uses AI. Check for mistakes.
Comment on lines +35 to 41
const age = user.age;
return {
userId: Number(user.id),
nickname: user.nickname,
gender: user.sex,
birthDate,
age,
area: {
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

getMe 응답을 age로 바꾸면, 사용자가 birthDate를 수정하는 기존 플로우(예: updateMe에서 birthdate 업데이트)가 있어도 age가 함께 갱신되지 않아 데이터가 쉽게 불일치할 수 있습니다. birthdate 변경 시 age를 재계산/동기화하거나, age를 저장값이 아닌 계산값으로 제공하는 방식으로 일관성을 보장해 주세요.

Copilot uses AI. Check for mistakes.
"@prisma/client": "7.2.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.3",
"cookie": "^1.1.1",
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

cookie-parsersrc/main.ts에서 사용되지만, cookie 패키지는 현재 코드베이스에서 import/사용되는 곳이 확인되지 않습니다. 불필요한 런타임 의존성은 제거하는 게 좋으니 cookie를 dependency에서 제외해 주세요(직접 파싱 로직은 이미 삭제됨).

Suggested change
"cookie": "^1.1.1",

Copilot uses AI. Check for mistakes.
Comment on lines 62 to 65
"@nestjs/testing": "^11.0.1",
"@types/cookie": "^0.6.0",
"@types/cookie-parser": "^1.4.10",
"@types/express": "^5.0.0",
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

@types/cookie가 코드에서 사용되지 않는 것으로 보입니다(현재 cookie 모듈도 미사용). 타입 패키지도 함께 제거해서 의존성/락파일 변경 범위를 줄여 주세요.

Copilot uses AI. Check for mistakes.
const birthdate = new Date(Date.UTC(year, month - 1, day));
if (Number.isNaN(birthdate.getTime())) {
return {};
}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

buildBirthInfo에서 new Date(Date.UTC(year, month - 1, day))는 잘못된 날짜(예: 02/31)를 자동으로 다음 달로 보정해 유효한 Date를 만들어버리므로, 현재의 NaN 체크로는 invalid birthday를 걸러내지 못합니다. 생성된 birthdate의 UTC year/month/day가 입력값과 정확히 일치하는지 추가 검증(또는 엄격한 파싱)을 넣어 잘못된 생일이 저장/나이 계산에 반영되지 않게 해주세요.

Suggested change
}
}
// Ensure that the constructed UTC date matches the input components exactly.
// This prevents dates like "0231" (Feb 31) from rolling over into the next month.
if (
birthdate.getUTCFullYear() !== year ||
birthdate.getUTCMonth() + 1 !== month ||
birthdate.getUTCDate() !== day
) {
return {};
}

Copilot uses AI. Check for mistakes.
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.

[Feature] 카카오 로그인 시 성별/생년월일 기반 User 정보 자동 생성/갱신

1 participant