User Management - kookmin-sw/capstone-2025-44 GitHub Wiki
π€ μ¬μ©μ κ΄λ¦¬ μμ€ν
Relevant Resource Files
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
- λ‘κ·Έμμ / νν΄ κΈ°λ₯
κ΄λ ¨ μμ€
- src/components/login/google-button.tsx
- src/components/login/kakao-button.tsx
- src/hooks/queries/useSignIn.tsx
- src/api/profile-api.tsx
- src/components/layout/profile-layout.tsx
- src/components/mypage/mypage-list-profile.tsx
2. μΈμ¦ μμ€ν
2.1 μΈμ¦ νλ¦
Google λ° Kakao μμ λ‘κ·ΈμΈ μ 곡μλ₯Ό ν΅ν λ‘κ·ΈμΈ μ§μ. λ‘κ·ΈμΈ μ±κ³΅ μ μ¬μ©μ ν ν°μ localStorageμ μ μ₯λ¨.
μΈμ¦ νλ¦:
- λ‘κ·ΈμΈ λ²νΌ ν΄λ¦
- μμ μ 곡μ μΈμ¦ νμ΄μ§λ‘ 리λλ μ
- μ¬μ©μ μΈμ¦ ν μΈμ¦ μ½λ/ν ν° λ°ν
- λ°±μλμ ν ν° μ λ¬ (/auth-service/api/v2/signin)
- λ°±μλλ‘λΆν° access/refresh ν ν° μμ
- localStorageμ μ μ₯
- κ²μκΈ λλ λ§μ΄νμ΄μ§λ‘ 리λλ μ
κ΄λ ¨ μμ€
- src/components/login/google-button.tsx
- src/components/login/kakao-button.tsx
- src/components/login/kakao-auth.tsx
- src/hooks/queries/useSignIn.tsx
2.2 Google λ‘κ·ΈμΈ
Firebase Authenticationμ μ¬μ©νλ©° Google μ 곡μλ₯Ό ν΅ν΄ μΈμ¦μ μν.
ν΅μ¬ ꡬν:
GoogleButton
μ»΄ν¬λνΈμμsignInWithRedirect
μ€ν- μΈμ¦ ν
getRedirectResult
λ‘ κ²°κ³Ό μμ - ν ν°μ
useSignIn
ν μΌλ‘ λ°±μλμ μ λ¬
κ΄λ ¨ μμ€
- src/components/login/google-button.tsx (20β28, 30β45)
2.3 Kakao λ‘κ·ΈμΈ
Kakao OAuth 2.0 μΈμ¦ νλ‘μ° μ¬μ©
ν΅μ¬ ꡬν:
KakaoButton
μμ Kakao μΈμ¦ URLλ‘ λ¦¬λλ μ KakaoAuth
μ»΄ν¬λνΈμμ 리λλ μ ν μΈμ¦ μ½λ μ²λ¦¬ λ° ν ν° μμ- ν ν°μ λ°±μλλ‘ μ μ‘
κ΄λ ¨ μμ€
- src/components/login/kakao-button.tsx (4β19)
- src/components/login/kakao-auth.tsx (20β45)
2.4 ν ν° μ μ₯
μ±κ³΅μ μΈ λ‘κ·ΈμΈ ν λ€μ μ 보λ₯Ό localStorageμ μ μ₯ν¨:
ν€ | μ©λ |
---|---|
accessToken | API μΈμ¦ μμ² μ μ¬μ© |
refreshToken | accessToken κ°±μ μ© |
userId | μ¬μ©μ κ³ μ μλ³μ |
role | μ¬μ©μ μν |
nickName | μ¬μ©μ λλ€μ |
κ΄λ ¨ μμ€
- src/hooks/queries/useSignIn.tsx (12β16)
- src/hooks/queries/usePostProfile.ts (19β21)
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
κ΄λ ¨ μμ€
- src/api/types/profile-type.ts (3β14)
3.2 νλ‘ν API
ProfileApi
ν΄λμ€λ λ€μ λ©μλλ₯Ό μ 곡:
λ©μλ | μ©λ | μλν¬μΈνΈ |
---|---|---|
getProfile | νλ‘ν μ‘°ν | /haetsal-service/api/v2/profile |
postProfile | μ νλ‘ν μμ± | /auth-service/api/v2/profile |
editProfile | νλ‘ν μμ | /haetsal-service/api/v2/profile |
κ΄λ ¨ μμ€
- src/api/profile-api.tsx (12β41)
3.3 νλ‘ν Context
ProfileContext
λ μ μμΌλ‘ μ¬μ©μ μ 보λ₯Ό 곡μ . ProfileLayout
μμ μ΄κΈ°νλ¨.
κ΄λ ¨ μμ€
4. λ§μ΄νμ΄μ§ μμ€ν
4.1 λ§μ΄νμ΄μ§ λ μ΄μμ
MypageListProfile
μ»΄ν¬λνΈ κ΅¬μ±:
- νλ‘ν μΉμ
- μκ³ μΉμ
- λ©λ΄ μΉμ
ν¬ν¨ μμ:
- νλ‘ν μ΄λ―Έμ§
- μ΄λ¦, μ±λ³, λμ΄
- νμνν μμ‘
- μ¬μ©μ μ£Όμ
- λμ νμ
- λλ‘λ€μ΄ λ©λ΄ (λ‘κ·Έμμ, νν΄, μ½κ΄ 보기 λ±)
κ΄λ ¨ μμ€
- src/components/mypage/mypage-list-profile.tsx (22β141)
- src/components/common/drop-down-menu.tsx (7β18)
4.2 νλ‘ν νμ
MypageListProfile
μμ λ€μ μ 보 μ 곡:
- νλ‘ν μ΄λ―Έμ§
- μ΄λ¦, μ±λ³, λμ΄
- μμΉ μ 보
- νμνν μμ‘
- κ±°λ μλ£ μ
κ΄λ ¨ μμ€
4.3 μ¬μ©μ μ‘μ
λλ‘λ€μ΄ λ©λ΄λ₯Ό ν΅ν΄ λ€μ μ‘μ κ°λ₯:
κΈ°λ₯ | μ€λͺ |
---|---|
λ‘κ·Έμμ | μ¬μ©μ λ‘κ·Έμμ |
νν΄ | μ¬μ©μ κ³μ μμ |
μ΄μ©μ½κ΄ 보기 | μ½κ΄ νμ΄μ§ νμ |
κ°μΈμ 보 μ²λ¦¬λ°©μΉ¨ 보기 | μ μ± νμ΄μ§ νμ |
κ΄λ ¨ μμ€
- src/components/mypage/mypage-list-profile.tsx (58β93, 123β137)
- src/pages/terms/user-terms.tsx
- src/pages/terms/privacy-policy.tsx
4.4 νλ‘ν μμ
νλ‘ν μ΄λ―Έμ§λ₯Ό ν΄λ¦νλ©΄ ProfileEditModal
μ΄ μ΄λ¦¬λ©° λ€μ νλͺ© μμ κ°λ₯:
- νλ‘ν μ΄λ―Έμ§
- λλ€μ
- μλ μμΌ
- μ±λ³
- μ£Όμ
κ΄λ ¨ μμ€
- src/components/mypage/mypage-list-profile.tsx (44, 117β122)
5. μμ€ν ν΅ν©
μ¬μ©μ κ΄λ¦¬ μμ€ν μ λ€μκ³Ό ν΅ν©λ©λλ€:
- μΈμ¦ λ° API μ κ·Ό: accessTokenμ ν΅ν΄ API νΈμΆ μΈμ¦
- κ²μκΈ μμ€ν : μ¬μ©μ νλ‘ν κΈ°λ° κ²μκΈ μ κ·Ό/μ§μ
- μ±ν μμ€ν : μ±ν λ°©μμ μ¬μ©μ νλ‘ν λ ΈμΆ
κ΄λ ¨ μμ€
6. μ΄μ©μ½κ΄ λ° κ°μΈμ 보μ²λ¦¬λ°©μΉ¨
react-notion-x
λΌμ΄λΈλ¬λ¦¬λ₯Ό μ¬μ©νμ¬ Notion νμ΄μ§μ λ΄μ©μ λ λλ§νμ¬ μ½κ΄κ³Ό μ μ±
μ μ 곡ν©λλ€.