fix: use userId param and restrict sensitive fields in profile endpoint#93
Closed
FuturMix wants to merge 1 commit into
Closed
fix: use userId param and restrict sensitive fields in profile endpoint#93FuturMix wants to merge 1 commit into
FuturMix wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
/api/user/profile/[userId]has two issues:Unused userId param: The
userIdis extracted from URL params but never used in the database query. The endpoint always returns the authenticated user's own profile, regardless of theuserIdin the URL.Sensitive data exposure:
select('*')returns all columns includingsalt,backup_pin_hash,phone_number, andauth_user_idin API responses.Fix
userIdparam to determine whether to return own or another user's profilesalt,backup_pin_hash,phone_number,auth_user_id)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.