diff --git a/src/lib/tenants/services/tenants.service.ts b/src/lib/tenants/services/tenants.service.ts index 587243e..0fa0774 100644 --- a/src/lib/tenants/services/tenants.service.ts +++ b/src/lib/tenants/services/tenants.service.ts @@ -43,9 +43,7 @@ export class TenantsService { if (tenant) { this.#logger.info('[TENANTS] Tenant from route: ', tenant); if (await this.selectTenant(tenant)) { - const intendedPath = window.location.pathname.replace(this.#baseHref, ''); - await this.#router.navigate([tenant], { skipLocationChange: true }); - await this.#router.navigateByUrl(intendedPath); + await this.#executeMainResolverAndRedirect(tenant); } return; } @@ -56,7 +54,7 @@ export class TenantsService { this.#logger.info('[TENANTS] Only one tenant loaded, auto-select it and redirect to login page'); const tenant = tenants[0].tenantId; if (await this.selectTenant(tenant)) { - await this.#router.navigate([tenant]); + await this.#executeMainResolverAndRedirect(tenant); } } } @@ -102,4 +100,11 @@ export class TenantsService { this.#storageReference.removeItem(tenant + ':' + key); }; } + + async #executeMainResolverAndRedirect(tenant: string) { + const intendedPath = window.location.pathname.replace(this.#baseHref, ''); + // TODO: Load roles in child routes canLoad functions so we can redirect straight to wanted URL + await this.#router.navigate([tenant], { skipLocationChange: true }); + await this.#router.navigate([intendedPath]); + } }