Skip to content

fix: use userId param and restrict sensitive fields in profile endpoint#93

Closed
FuturMix wants to merge 1 commit into
profullstack:masterfrom
FuturMix:fix/user-profile-userid-ignored
Closed

fix: use userId param and restrict sensitive fields in profile endpoint#93
FuturMix wants to merge 1 commit into
profullstack:masterfrom
FuturMix:fix/user-profile-userid-ignored

Conversation

@FuturMix

Copy link
Copy Markdown

Bug

/api/user/profile/[userId] has two issues:

  1. Unused userId param: The userId is extracted from URL params but never used in the database query. The endpoint always returns the authenticated user's own profile, regardless of the userId in the URL.

  2. Sensitive data exposure: select('*') returns all columns including salt, backup_pin_hash, phone_number, and auth_user_id in API responses.

Fix

  • Use the userId param to determine whether to return own or another user's profile
  • Own profile: return all non-sensitive fields (excludes salt, backup_pin_hash, phone_number, auth_user_id)
  • Other user's profile: return only public fields (id, username, display_name, avatar_url, bio, website, unique_identifier, status, is_online)

This is consistent with the existing pattern in /api/users/by-id/[identifier] and /api/users/by-username/[username] which already return limited public fields.

The /api/user/profile/[userId] endpoint extracted the userId from
URL params but never used it — every request returned the
authenticated user's own profile regardless of the userId.

Additionally, select('*') returned all columns including sensitive
fields (salt, backup_pin_hash, phone_number, auth_user_id).

Changes:
- Use the userId param to look up the requested user's profile
- Return expanded fields for own profile, public fields only for
  other users' profiles
- Exclude sensitive columns (salt, backup_pin_hash, phone_number,
  auth_user_id) from all responses
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.

2 participants