Commit 60df40e
committed
feat: replace mock user helpers with Prisma-backed profile API
- Add firstName, lastName, bio, avatar fields to User model in Prisma schema
- Add LearnerProfile model with display name, country, timezone, languages,
skill level, interests, goals, and visibility/consent controls
- Add OnboardingState model tracking profile completion, email verification,
wallet connection, session booking, credential earning, and consent
- Create user.service.ts with Prisma-backed methods:
- findUserById with profile, onboarding, and profile completion
- updateUserProfile with audit logging
- updateUserProfileData for LearnerProfile upsert
- validatePassword using bcrypt.compare
- updateUserPassword using bcrypt hash
- updateUserWallet with onboarding state update
- getPublicProfile with consent-aware visibility check
- getProfileCompletion and getOnboardingState
- Update UserController to use service instead of mock helpers
- Add audit logging for PROFILE_UPDATED, PASSWORD_CHANGED, WALLET_UPDATED
- Add public profile read respecting LearnerProfile visibility
- Return profileCompletion and onboardingState in user responses
- Add GET /me/profile route for extended profile
- Update tests to mock Prisma instead of spying on private methods
- All 318 tests pass, TypeScript compiles cleanly
Closes: #851 parent 53aa17a commit 60df40e
7 files changed
Lines changed: 954 additions & 597 deletions
File tree
- prisma
- src
- controllers
- routes/v1
- services
- types
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| |||
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
38 | 83 | | |
39 | 84 | | |
40 | 85 | | |
| |||
0 commit comments