fix(account): allow user tokens to look up accounts by social key - #11003
Open
IamCoder18 wants to merge 1 commit into
Open
fix(account): allow user tokens to look up accounts by social key#11003IamCoder18 wants to merge 1 commit into
IamCoder18 wants to merge 1 commit into
Conversation
findPersonBySocialKey is a read-only lookup used by both the front-end and CLI clients to resolve a social-key (e.g. email) to a person or account. The service-token gate it inherited was silently rejecting every regular user JWT, so every cross-workspace user lookup failed with Forbidden. Drop the gate; the underlying db.socialId.findOne / db.account.findOne reads are intentional and safe. Tests cover the user-token success path, requireAccount=true variant, empty-string rejection, and the missing-key not-found path. Signed-off-by: Aarav Sharma <iamcoder18@gmail.com>
IamCoder18
force-pushed
the
fix/account-find-person-by-social-key
branch
from
August 4, 2026 02:21
6095fce to
465d25e
Compare
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.
Context
Looking up an account by social key is something any logged in user should be able to do. The function that handles it was rejecting every regular user token with a Forbidden error, so lookups failed. My CLI at https://github.com/IamCoder18/huly-cli requires this functionality.
Implementation
I removed the service-token gate. The function still throws a BadRequest when the social key is empty, looks up the person by key, and returns the account UUID when the caller asks for one and the person has an account. The reads themselves are intentional and safe to expose to any authenticated user.
Tests
Added a small describe block covering the user-token success path, empty-input rejection, the missing-key case, and both flavors of requireAccount (account present and no account).