Skip to content

Conversation

@vivesing
Copy link
Contributor

Add User Details API Endpoints

Summary

Added two new API endpoints to fetch user details (name, email) for trial users with IMS fallback support for admin users.

Changes

New Controller: user-details.js

  • GET /organizations/:organizationId/userDetails/:externalUserId

    • Returns user details for a single external user ID
    • Fetches from trial users database first
    • Falls back to IMS API if user not found and requestor is admin
    • Returns system defaults for non-admin users
  • POST /organizations/:organizationId/userDetails

    • Bulk endpoint accepting array of user IDs in request body
    • Returns object with externalUserId as key and user details as value
    • Logs count of IMS API calls for monitoring
    • Handles mixed results (some from DB, some from IMS)

Features

  • ✅ Access control validation (organization membership)
  • ✅ Admin-only IMS fallback (non-admins get system defaults)
  • ✅ Graceful error handling (IMS failures return system defaults)
  • ✅ Monitoring: Logs IMS call count per request
  • ✅ Fallback values for incomplete IMS profiles

User Details Response

{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"organizationId": "org-id"
}### Tests

  • 22 test cases with 100% code coverage
  • Edge cases: admin vs non-admin, IMS success/failure, incomplete data
  • Route integration tests updated

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description. Or if there's no issue created, make sure you
    describe here the problem you're solving.
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

If the PR is changing the API specification:

  • make sure you add a "Not implemented yet" note the endpoint description, if the implementation is not ready
    yet. Ideally, return a 501 status code with a message explaining the feature is not implemented yet.
  • make sure you add at least one example of the request and response.

If the PR is changing the API implementation or an entity exposed through the API:

  • make sure you update the API specification and the examples to reflect the changes.

If the PR is introducing a new audit type:

  • make sure you update the API specification with the type, schema of the audit result and an example

Related Issues

Thanks for contributing!

@github-actions
Copy link

This PR will trigger a minor release when merged.

@vivesing vivesing requested a review from ravverma November 28, 2025 12:39
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@vivesing vivesing requested a review from ravverma December 1, 2025 11:50
@vivesing
Copy link
Contributor Author

vivesing commented Dec 2, 2025

for non admin users, if user could not be found in the TrialUsers list we assume its either service user or admin user which is not part of the imsOrg so returning system in that case. Once we have required scope added in the ims client we will be able to identify users who are not part of the IMS group in a better way

@vivesing vivesing requested a review from ravverma December 2, 2025 07:12
@vivesing vivesing merged commit 3de93ed into main Dec 2, 2025
9 checks passed
@vivesing vivesing deleted the feat/user-details branch December 2, 2025 07:55
solaris007 pushed a commit that referenced this pull request Dec 2, 2025
# [1.266.0](v1.265.3...v1.266.0) (2025-12-02)

### Features

* llmo-1539 new endpoint to get user details ([#1585](#1585)) ([3de93ed](3de93ed))
@solaris007
Copy link
Member

🎉 This PR is included in version 1.266.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants