0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(console): update value of the last-visited tenant wildcard (#6787)

This commit is contained in:
Charles Zhao 2024-11-12 11:20:58 +08:00 committed by GitHub
parent 04992b1565
commit 8e0d717781
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View file

@ -71,8 +71,9 @@ export default function TenantAccess() {
isAuthenticated && isAuthenticated &&
currentTenantId && currentTenantId &&
// The current tenant is unavailable to the user, maybe a deleted tenant or a tenant that // The current tenant is unavailable to the user, maybe a deleted tenant or a tenant that
// the user has no access to. Try with prepended default tenant ID, or if it's not available, // the user has no access to.
// redirect to the home page. // If the current tenant ID equals the reserved wildcard "to", replace it with the last
// visited tenant ID and keeping the rest of the URL path, otherwise redirect to home page.
!currentTenant !currentTenant
) { ) {
if (isCloud && defaultTenantId && currentTenantId === reservedTenantIdWildcard) { if (isCloud && defaultTenantId && currentTenantId === reservedTenantIdWildcard) {

View file

@ -35,11 +35,16 @@ const reservedRoutes: Readonly<string[]> = Object.freeze([
]); ]);
/** /**
* The reserved tenant ID wildcard for the default tenant. Useful when specifying a console URL in * The reserved tenant ID wildcard for the last-visited tenant. Useful when specifying a console URL in
* the documentation or other places where the tenant ID is not known. Will be replaced with the * the documentation or other places where the actual user tenant ID is unknown. The wildcard value "to"
* actual default tenant ID in the runtime. * will be replaced by the detected last-visited tenant ID in the runtime.
*
* @example
* ```md
* [Console > Applications](https://cloud.logto.io/to/applications)
* ```
*/ */
export const reservedTenantIdWildcard = 'default'; export const reservedTenantIdWildcard = 'to';
/** @see {@link TenantsProvider} for why `useSWR()` is not applicable for this context. */ /** @see {@link TenantsProvider} for why `useSWR()` is not applicable for this context. */
type Tenants = { type Tenants = {