[BUG-1427] Newly created user defaults to same tenant as admin when using same browser window. #1614
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.
Description
Fixes bug that defaults a new user to the Global tenant, even when they do not have permission for the Global tenant and this option is blocked out on the modal. To fix this, I added a new check to the resolveTenantName function, in which it checks of whether the Global tenant is available for this account through a new parameter to the function, in that case it skips over the Global tenant return and returns a Private tenant.
Category
Bug fix
Why these changes are required?
New users were having the Global tenant role even when they don't have the permissions to, which is a security risk.
What is the old behavior before changes and new behavior after changes?
Old behavior: When you select global tenant on the admin account then switch to a new user, this global tenant is selected by default even when this option is not available since the new user doesn't have access to the Global tenant.
New behavior: In this case, the default option automatically switches to the next accessible role, which is the Private tenant.
Issues Resolved
Fixed issue #1427
Testing
Manually tested to make sure nothing was broken. Additionally added new tests to tenant-utils.test.tsx to update function and test for cases where the global tenant is not enabled.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.