|
|
@ -8,6 +8,7 @@ import { FindTenantResultDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-te |
|
|
import { EnvironmentService } from '../services/environment.service'; |
|
|
import { EnvironmentService } from '../services/environment.service'; |
|
|
import { MultiTenancyService } from '../services/multi-tenancy.service'; |
|
|
import { MultiTenancyService } from '../services/multi-tenancy.service'; |
|
|
import { createTokenParser } from './string-utils'; |
|
|
import { createTokenParser } from './string-utils'; |
|
|
|
|
|
import { firstValueFrom } from 'rxjs'; |
|
|
|
|
|
|
|
|
const tenancyPlaceholder = '{0}'; |
|
|
const tenancyPlaceholder = '{0}'; |
|
|
|
|
|
|
|
|
@ -24,6 +25,7 @@ function getCurrentTenancyNameFromUrl(tenantKey: string) { |
|
|
return urlParams.get(tenantKey); |
|
|
return urlParams.get(tenantKey); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export async function parseTenantFromUrl(injector: Injector) { |
|
|
export async function parseTenantFromUrl(injector: Injector) { |
|
|
const environmentService = injector.get(EnvironmentService); |
|
|
const environmentService = injector.get(EnvironmentService); |
|
|
const multiTenancyService = injector.get(MultiTenancyService); |
|
|
const multiTenancyService = injector.get(MultiTenancyService); |
|
|
@ -49,16 +51,26 @@ export async function parseTenantFromUrl(injector: Injector) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (tenancyName) { |
|
|
if (tenancyName) { |
|
|
|
|
|
debugger |
|
|
/** |
|
|
/** |
|
|
* We have to replace tenant name within the urls from environment, |
|
|
* We have to replace tenant name within the urls from environment, |
|
|
* because the code below will make a http request to find information about the domain tenant. |
|
|
* because the code below will make a http request to find information about the domain tenant. |
|
|
* Before this request takes place, we need to replace placeholders aka "{0}". |
|
|
* Before this request takes place, we need to replace placeholders aka "{0}". |
|
|
*/ |
|
|
*/ |
|
|
replaceTenantNameWithinEnvironment(injector, tenancyName); |
|
|
replaceTenantNameWithinEnvironment(injector, tenancyName); |
|
|
return multiTenancyService |
|
|
|
|
|
.setTenantByName(tenancyName) |
|
|
const tenant$ = multiTenancyService |
|
|
.pipe(tap(setEnvironmentWithDomainTenant)) |
|
|
.setTenantByName(tenancyName) |
|
|
.toPromise(); |
|
|
.pipe(tap(setEnvironmentWithDomainTenant)) |
|
|
|
|
|
try { |
|
|
|
|
|
const result = await firstValueFrom(tenant$) |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
catch (error) { |
|
|
|
|
|
|
|
|
|
|
|
console.log(error) |
|
|
|
|
|
debugger |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
/** |
|
|
/** |
|
|
* If there is no tenant, we still have to clean up {0}. from baseUrl to avoid incorrect http requests. |
|
|
* If there is no tenant, we still have to clean up {0}. from baseUrl to avoid incorrect http requests. |
|
|
|