Skip to content

Fixes missing detail in userByEmail() query#4061

Open
bomoko wants to merge 2 commits intomainfrom
fix-platformrole-in-userbyemail
Open

Fixes missing detail in userByEmail() query#4061
bomoko wants to merge 2 commits intomainfrom
fix-platformrole-in-userbyemail

Conversation

@bomoko
Copy link
Copy Markdown
Contributor

@bomoko bomoko commented Mar 12, 2026

This PR enhances the user model with a convenience function that lets one enrich a user object with the platform roles.
This is then used to plug a hole in the current "userByEmail()" query, which doesn't actually return platform roles.

The enrichment is gated by the same logic used by the allPlatformUsers query.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 12, 2026

Overview

Image reference testlagoon/api:main lagoon/api:ci-latest
- digest 0d14b0f95e76 f06e0aba7e3d
- tag main ci-latest
- provenance https://github.com/uselagoon/lagoon.git/commit/0d819c17d837348f83cbca5ad2f94b7245dba137
- vulnerabilities critical: 3 high: 40 medium: 21 low: 8 critical: 3 high: 40 medium: 21 low: 8
- platform linux/amd64 linux/amd64
- size 151 MB 182 MB (+31 MB)
- packages 1579 1579
Base Image node:22-alpine
also known as:
22-alpine3.23
22.22-alpine
22.22-alpine3.23
jod-alpine
jod-alpine3.23
node:22-alpine
also known as:
22-alpine3.23
22.22-alpine
22.22-alpine3.23
jod-alpine
jod-alpine3.23
- vulnerabilities critical: 0 high: 10 medium: 2 low: 2 critical: 0 high: 10 medium: 2 low: 2

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the API user lookup so that userByEmail() can optionally return a user’s platform roles by enriching the loaded user object, using the same gating logic as the platform-admin “all platform users” flow.

Changes:

  • Add UserModel.enrichUserWithPlatformRoles() to fetch and attach Keycloak realm platform roles to a User.
  • Update getUserByEmail resolver to enrich the returned user with platformRoles for platform owners/viewers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
services/api/src/resources/user/resolvers.ts Enriches userByEmail results with platform roles when caller has platform admin scopes.
services/api/src/models/user.ts Adds a model helper to fetch realm role mappings and attach platform roles to the user object.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread services/api/src/models/user.ts Outdated
Comment thread services/api/src/models/user.ts Outdated
Comment thread services/api/src/resources/user/resolvers.ts Outdated
@bomoko bomoko requested a review from shreddedbacon March 12, 2026 19:41
Copy link
Copy Markdown
Member

@shreddedbacon shreddedbacon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran locally, roles in userByEmail query are populated as expected.

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.

4 participants