Skip to content

fix(account): allow user tokens to look up accounts by social key - #11003

Open
IamCoder18 wants to merge 1 commit into
hcengineering:developfrom
IamCoder18:fix/account-find-person-by-social-key
Open

fix(account): allow user tokens to look up accounts by social key#11003
IamCoder18 wants to merge 1 commit into
hcengineering:developfrom
IamCoder18:fix/account-find-person-by-social-key

Conversation

@IamCoder18

@IamCoder18 IamCoder18 commented Aug 4, 2026

Copy link
Copy Markdown

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).

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
IamCoder18 force-pushed the fix/account-find-person-by-social-key branch from 6095fce to 465d25e Compare August 4, 2026 02:21
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.

1 participant