privacy
Enforces public vs private user profiles before returning UserProfileData.
PrivacyCheckResult
| Field | Meaning |
|---|---|
allowed | Viewer may see the profile |
profile | Loaded row when allowed |
error | Message when denied |
statusCode | 404, 403, or 500 |
Functions
checkProfilePrivacyById(profileId)— Load by database id viagetUserProfileByDatabaseId.checkProfilePrivacyByUserId(userId)— Load by user id viagetUserProfileById.withProfilePrivacy(identifier, isUserId?)— Returns a readyResponseJSON error or{ profile }for route handlers.
Rules
- Missing profile → 404.
profile_public !== false→ allowed for everyone.- Private profile → allowed only when session user id matches profile owner id (string compare).
- Uncaught errors → 500.
Uses auth() from @/lib/auth for the current session.
Sources: src/lib/utils/privacy.ts, src/lib/actions/profile.actions.ts