Skip to content

feat: show organization username in impersonation banner#24313

Merged
hariombalhara merged 3 commits intomainfrom
devin/impersonation-banner-org-username-1759809641
Oct 8, 2025
Merged

feat: show organization username in impersonation banner#24313
hariombalhara merged 3 commits intomainfrom
devin/impersonation-banner-org-username-1759809641

Conversation

@hariombalhara
Copy link
Member

@hariombalhara hariombalhara commented Oct 7, 2025

What does this PR do?

Updates the impersonation banner to display the organization-aware username (orgAwareUsername) instead of the regular username when impersonating organization members. This ensures that when impersonating a user who belongs to an organization, their organization-specific username is shown in the banner rather than their global username.

Global username doesn't have any use as long as user is part of organization

For owner1 member of Acme org, now we show the username in the Organization
Before:
image

After:
image

Link to Devin run: https://app.devin.ai/sessions/8b52f231e47f48b59c1a29d96ae44b2a

Requested by: @hariombalhara

Implementation Details

  • File changed: packages/features/ee/impersonation/components/ImpersonatingBanner.tsx
  • Change: Uses data.user.orgAwareUsername || data.user.username instead of data.user.username
  • Approach: Leverages existing session data (orgAwareUsername) that's already populated during JWT token creation
  • Fallback: Gracefully falls back to regular username for non-organization users

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

⚠️ Critical Testing Required: This change affects the impersonation flow which requires specific setup:

  1. Setup Requirements:

    • Organization with members
    • Users with different usernames at global vs organization level
    • Admin user with impersonation permissions
  2. Test Scenarios:

    • Impersonate an organization member → Should show their org-specific username
    • Impersonate a regular user (non-org) → Should show their regular username
    • Verify banner text displays correctly in both cases
  3. Expected Behavior:

    • Input: Impersonating user "john.doe" who has org username "john" in organization "acme"
    • Output: Banner should show "john" (org username) not "john.doe" (global username)

Key Review Points

  • Verify orgAwareUsername contains the expected organization username (not global username)
  • Test impersonation banner with organization members vs regular users
  • Confirm session data structure matches expectations
  • Ensure fallback to regular username works for non-org users
  • Validate that this change aligns with the original requirement to show usernameInOrg

Checklist

  • My code follows the style guidelines of this project
  • I have checked if my changes generate no new warnings
  • Type checking, linting, and unit tests all pass

- Update ImpersonatingBanner to use orgAwareUsername field from session
- Falls back to regular username for non-organization users
- Uses existing session data without additional queries

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Oct 7, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 7, 2025

Walkthrough

The impersonation banner text in packages/features/ee/impersonation/components/ImpersonatingBanner.tsx was updated to display data.user.orgAwareUsername when available, with a fallback to data.user.username. This change only affects the string passed to the TopBanner text prop and does not modify any other logic or control flow.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title accurately summarizes the core feature update by indicating that the impersonation banner will now display the organization-specific username when available. It is concise, clear, and directly reflects the change made in the components file without extraneous details. It follows conventional commit style by prefixing with feat: and using plain language to highlight the main change.
Description Check ✅ Passed The description clearly outlines the change to display orgAwareUsername in the impersonation banner, along with implementation details and testing steps. It directly pertains to the modifications made in the components file and provides relevant context such as screenshots and a link to the Devin run. The description remains focused on the changeset and does not include unrelated information.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/impersonation-banner-org-username-1759809641

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3fc8c6c and 0fbf74d.

📒 Files selected for processing (1)
  • packages/features/ee/impersonation/components/ImpersonatingBanner.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/features/ee/impersonation/components/ImpersonatingBanner.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/ee/impersonation/components/ImpersonatingBanner.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/ee/impersonation/components/ImpersonatingBanner.tsx
🔇 Additional comments (1)
packages/features/ee/impersonation/components/ImpersonatingBanner.tsx (1)

20-20: Review nullish fallback choice: orgAwareUsername is declared as an optional string in packages/types/next-auth.d.ts and is always set in session. Using || will fallback on any falsy value (including ""); ?? only falls back on null/undefined. Switch to ?? only if you don’t want to treat empty strings as a trigger.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hariombalhara hariombalhara marked this pull request as ready for review October 7, 2025 04:20
@hariombalhara hariombalhara self-assigned this Oct 7, 2025
@graphite-app graphite-app bot requested a review from a team October 7, 2025 04:20
@hariombalhara hariombalhara requested review from alishaz-polymath and removed request for a team October 7, 2025 04:20
@dosubot dosubot bot added the ✨ feature New feature or request label Oct 7, 2025
Copy link
Contributor

@anikdhabal anikdhabal left a comment

Choose a reason for hiding this comment

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

LGTM

@vercel
Copy link

vercel bot commented Oct 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Oct 8, 2025 11:06am
cal-eu Ignored Ignored Oct 8, 2025 11:06am

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2025

E2E results are ready!

@hariombalhara hariombalhara enabled auto-merge (squash) October 8, 2025 11:06
@hariombalhara hariombalhara merged commit 64f811e into main Oct 8, 2025
35 of 36 checks passed
@hariombalhara hariombalhara deleted the devin/impersonation-banner-org-username-1759809641 branch October 8, 2025 11:32
joeauyeung pushed a commit that referenced this pull request Oct 9, 2025
- Update ImpersonatingBanner to use orgAwareUsername field from session
- Falls back to regular username for non-organization users
- Uses existing session data without additional queries

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ✨ feature New feature or request ready-for-e2e size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants