User Management - kookmin-sw/capstone-2025-44 GitHub Wiki

πŸ‘€ μ‚¬μš©μž 관리 μ‹œμŠ€ν…œ

Relevant Resource Files

src/api/profile-api.tsx

src/api/types/profile-type.ts

src/assets/icons/dots-menu.svg

src/components/common/drop-down-menu.tsx

src/components/layout/profile-layout.tsx

src/components/login/google-button.tsx

src/components/login/kakao-auth.tsx

src/components/login/kakao-button.tsx

src/components/mypage/mypage-list-profile.tsx

src/hooks/queries/usePostProfile.ts

src/hooks/queries/useSignIn.tsx

src/pages/terms/privacy-policy.tsx

src/pages/terms/user-terms.tsx

λͺ©μ  및 λ²”μœ„

이 λ¬Έμ„œλŠ” νƒ€μž„νŽ˜μ΄ ν”„λ‘ νŠΈμ—”λ“œ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ˜ μ‚¬μš©μž 관리 μ‹œμŠ€ν…œμ— λŒ€ν•΄ μ„€λͺ…ν•©λ‹ˆλ‹€. μ‚¬μš©μž 관리 μ‹œμŠ€ν…œμ€ μ‚¬μš©μž 인증(μ†Œμ…œ 둜그인 포함), ν”„λ‘œν•„ 관리, λ§ˆμ΄νŽ˜μ΄μ§€ κΈ°λŠ₯을 λ‹΄λ‹Ήν•˜λ©°, μ• ν”Œλ¦¬μΌ€μ΄μ…˜ λ‚΄μ—μ„œ μ‚¬μš©μž μ •μ²΄μ„±μ˜ κΈ°λ°˜μ„ μ œκ³΅ν•©λ‹ˆλ‹€.

1. μ‹œμŠ€ν…œ κ°œμš”

νƒ€μž„νŽ˜μ΄ μ‚¬μš©μž 관리 μ‹œμŠ€ν…œμ€ λ‹€μŒ μ„Έ κ°€μ§€ μ£Όμš” ν•˜μœ„ μ‹œμŠ€ν…œμœΌλ‘œ κ΅¬μ„±λ©λ‹ˆλ‹€:

  • 인증(Authentication): Google, Kakaoλ₯Ό ν†΅ν•œ μ†Œμ…œ 둜그인 처리
  • ν”„λ‘œν•„ 관리(Profile Management): μ‚¬μš©μž ν”„λ‘œν•„ 정보 관리 및 μˆ˜μ •
  • λ§ˆμ΄νŽ˜μ΄μ§€(MyPage): μ‚¬μš©μž 개인 정보 및 계정 κ΄€λ ¨ κΈ°λŠ₯ 제곡

λ§ˆμ΄νŽ˜μ΄μ§€ ꡬ성 μš”μ†Œ

  • ν”„λ‘œν•„ μ»΄ν¬λ„ŒνŠΈ
  • 인증 μ»΄ν¬λ„ŒνŠΈ
  • 곡톡 μ»΄ν¬λ„ŒνŠΈ

ꡬ성

  • GoogleButton
  • KakaoButton
  • useSignIn
  • Local Storage Tokens
  • ProfileApi
  • ProfileEditModal
  • ProfileContext
  • MypageListProfile
  • DropDownMenu
  • λ‘œκ·Έμ•„μ›ƒ / νƒˆν‡΄ κΈ°λŠ₯

κ΄€λ ¨ μ†ŒμŠ€

2. 인증 μ‹œμŠ€ν…œ

2.1 인증 흐름

Google 및 Kakao μ†Œμ…œ 둜그인 제곡자λ₯Ό ν†΅ν•œ 둜그인 지원. 둜그인 성곡 μ‹œ μ‚¬μš©μž 토큰은 localStorage에 μ €μž₯됨.

인증 흐름:

  1. 둜그인 λ²„νŠΌ 클릭
  2. μ†Œμ…œ 제곡자 인증 νŽ˜μ΄μ§€λ‘œ λ¦¬λ””λ ‰μ…˜
  3. μ‚¬μš©μž 인증 ν›„ 인증 μ½”λ“œ/토큰 λ°˜ν™˜
  4. λ°±μ—”λ“œμ— 토큰 전달 (/auth-service/api/v2/signin)
  5. λ°±μ—”λ“œλ‘œλΆ€ν„° access/refresh 토큰 μˆ˜μ‹ 
  6. localStorage에 μ €μž₯
  7. κ²Œμ‹œκΈ€ λ˜λŠ” λ§ˆμ΄νŽ˜μ΄μ§€λ‘œ λ¦¬λ””λ ‰μ…˜

κ΄€λ ¨ μ†ŒμŠ€

2.2 Google 둜그인

Firebase Authentication을 μ‚¬μš©ν•˜λ©° Google 제곡자λ₯Ό 톡해 인증을 μˆ˜ν–‰.

핡심 κ΅¬ν˜„:

  • GoogleButton μ»΄ν¬λ„ŒνŠΈμ—μ„œ signInWithRedirect μ‹€ν–‰
  • 인증 ν›„ getRedirectResult둜 κ²°κ³Ό μˆ˜μ‹ 
  • 토큰을 useSignIn ν›…μœΌλ‘œ λ°±μ—”λ“œμ— 전달

κ΄€λ ¨ μ†ŒμŠ€

2.3 Kakao 둜그인

Kakao OAuth 2.0 인증 ν”Œλ‘œμš° μ‚¬μš©

핡심 κ΅¬ν˜„:

  • KakaoButtonμ—μ„œ Kakao 인증 URL둜 λ¦¬λ””λ ‰μ…˜
  • KakaoAuth μ»΄ν¬λ„ŒνŠΈμ—μ„œ λ¦¬λ””λ ‰μ…˜ ν›„ 인증 μ½”λ“œ 처리 및 토큰 μˆ˜μ‹ 
  • 토큰을 λ°±μ—”λ“œλ‘œ 전솑

κ΄€λ ¨ μ†ŒμŠ€

2.4 토큰 μ €μž₯

성곡적인 둜그인 ν›„ λ‹€μŒ 정보λ₯Ό localStorage에 μ €μž₯함:

ν‚€ μš©λ„
accessToken API 인증 μš”μ²­ μ‹œ μ‚¬μš©
refreshToken accessToken κ°±μ‹ μš©
userId μ‚¬μš©μž 고유 μ‹λ³„μž
role μ‚¬μš©μž μ—­ν• 
nickName μ‚¬μš©μž λ‹‰λ„€μž„

κ΄€λ ¨ μ†ŒμŠ€

3. ν”„λ‘œν•„ 관리

3.1 ν”„λ‘œν•„ 데이터 ꡬ쑰

ProfileData νƒ€μž… μ •μ˜:

userId: number
nickName: string
gender: "male" | "female"
address: string
birth: string
ageRange: number
accountNumber: string
profileImage: string
blocked: boolean
dealCount: number

κ΄€λ ¨ μ†ŒμŠ€

3.2 ν”„λ‘œν•„ API

ProfileApi ν΄λž˜μŠ€λŠ” λ‹€μŒ λ©”μ„œλ“œλ₯Ό 제곡:

λ©”μ„œλ“œ μš©λ„ μ—”λ“œν¬μΈνŠΈ
getProfile ν”„λ‘œν•„ 쑰회 /haetsal-service/api/v2/profile
postProfile μƒˆ ν”„λ‘œν•„ 생성 /auth-service/api/v2/profile
editProfile ν”„λ‘œν•„ μˆ˜μ • /haetsal-service/api/v2/profile

κ΄€λ ¨ μ†ŒμŠ€

3.3 ν”„λ‘œν•„ Context

ProfileContextλŠ” μ „μ—­μœΌλ‘œ μ‚¬μš©μž 정보λ₯Ό 곡유. ProfileLayoutμ—μ„œ μ΄ˆκΈ°ν™”λ¨.

κ΄€λ ¨ μ†ŒμŠ€

4. λ§ˆμ΄νŽ˜μ΄μ§€ μ‹œμŠ€ν…œ

4.1 λ§ˆμ΄νŽ˜μ΄μ§€ λ ˆμ΄μ•„μ›ƒ

MypageListProfile μ»΄ν¬λ„ŒνŠΈ ꡬ성:

  • ν”„λ‘œν•„ μ„Ήμ…˜
  • μž”κ³  μ„Ήμ…˜
  • 메뉴 μ„Ήμ…˜

포함 μš”μ†Œ:

  • ν”„λ‘œν•„ 이미지
  • 이름, 성별, λ‚˜μ΄
  • νƒ€μž„ν™”ν μž”μ•‘
  • μ‚¬μš©μž μ£Όμ†Œ
  • 도움 횟수
  • λ“œλ‘­λ‹€μš΄ 메뉴 (λ‘œκ·Έμ•„μ›ƒ, νƒˆν‡΄, μ•½κ΄€ 보기 λ“±)

κ΄€λ ¨ μ†ŒμŠ€

4.2 ν”„λ‘œν•„ ν‘œμ‹œ

MypageListProfileμ—μ„œ λ‹€μŒ 정보 제곡:

  • ν”„λ‘œν•„ 이미지
  • 이름, 성별, λ‚˜μ΄
  • μœ„μΉ˜ 정보
  • νƒ€μž„ν™”ν μž”μ•‘
  • 거래 μ™„λ£Œ 수

κ΄€λ ¨ μ†ŒμŠ€

4.3 μ‚¬μš©μž μ•‘μ…˜

λ“œλ‘­λ‹€μš΄ 메뉴λ₯Ό 톡해 λ‹€μŒ μ•‘μ…˜ κ°€λŠ₯:

κΈ°λŠ₯ μ„€λͺ…
λ‘œκ·Έμ•„μ›ƒ μ‚¬μš©μž λ‘œκ·Έμ•„μ›ƒ
νƒˆν‡΄ μ‚¬μš©μž 계정 μ‚­μ œ
μ΄μš©μ•½κ΄€ 보기 μ•½κ΄€ νŽ˜μ΄μ§€ ν‘œμ‹œ
κ°œμΈμ •λ³΄ 처리방침 보기 μ •μ±… νŽ˜μ΄μ§€ ν‘œμ‹œ

κ΄€λ ¨ μ†ŒμŠ€

4.4 ν”„λ‘œν•„ μˆ˜μ •

ν”„λ‘œν•„ 이미지λ₯Ό ν΄λ¦­ν•˜λ©΄ ProfileEditModal이 열리며 λ‹€μŒ ν•­λͺ© μˆ˜μ • κ°€λŠ₯:

  • ν”„λ‘œν•„ 이미지
  • λ‹‰λ„€μž„
  • 생년월일
  • 성별
  • μ£Όμ†Œ

κ΄€λ ¨ μ†ŒμŠ€

5. μ‹œμŠ€ν…œ 톡합

μ‚¬μš©μž 관리 μ‹œμŠ€ν…œμ€ λ‹€μŒκ³Ό ν†΅ν•©λ©λ‹ˆλ‹€:

  • 인증 및 API μ ‘κ·Ό: accessToken을 톡해 API 호좜 인증
  • κ²Œμ‹œκΈ€ μ‹œμŠ€ν…œ: μ‚¬μš©μž ν”„λ‘œν•„ 기반 κ²Œμ‹œκΈ€ μ ‘κ·Ό/지원
  • μ±„νŒ… μ‹œμŠ€ν…œ: μ±„νŒ…λ°©μ—μ„œ μ‚¬μš©μž ν”„λ‘œν•„ λ…ΈμΆœ

κ΄€λ ¨ μ†ŒμŠ€

6. μ΄μš©μ•½κ΄€ 및 κ°œμΈμ •λ³΄μ²˜λ¦¬λ°©μΉ¨

react-notion-x 라이브러리λ₯Ό μ‚¬μš©ν•˜μ—¬ Notion νŽ˜μ΄μ§€μ˜ λ‚΄μš©μ„ λ Œλ”λ§ν•˜μ—¬ μ•½κ΄€κ³Ό 정책을 μ œκ³΅ν•©λ‹ˆλ‹€.

κ΄€λ ¨ μ†ŒμŠ€