Fix duplicate tenant display in account selector #660
Merged
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.
Summary
Fixed a bug where users with access to a tenant via both domain-based authorization and email-based authorization would see the tenant twice in the account selector.
Problem
When a user had access to a tenant through both
authorized_domainsandauthorized_emails, the tenant appeared twice in the tenant selection screen during login.Root Cause
In the
google_callback()function, tenants were being added to theavailable_tenantslist without checking for duplicates. The code would add:domain_tenant(domain-based access)email_tenants(email-based access)Solution
Refactored the tenant collection logic to use a dictionary keyed by
tenant_idfor deduplication:Testing
Added comprehensive unit test
test_tenant_not_duplicated_when_in_both_domain_and_email_liststhat verifies:Changes
src/admin/blueprints/auth.py:268-307to use deduplication logicsrc/admin/tests/unit/test_auth.py:295-363Impact