From 8e88fa69d3d35e2716565c2c969dce9c03a5a17c Mon Sep 17 00:00:00 2001 From: bnymncoskuner Date: Mon, 12 Jul 2021 16:38:43 +0300 Subject: [PATCH 1/7] feat: remove tenantId from reset-password request --- .../components/reset-password/reset-password.component.ts | 5 +---- .../packages/account/src/lib/proxy/account/models.ts | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts b/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts index b84c6db3a3..5e311e7b83 100644 --- a/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts @@ -18,7 +18,6 @@ export class ResetPasswordComponent implements OnInit { inProgress = false; isPasswordReset = false; - tenantId = ''; mapErrorsFn: Validation.MapErrorsFn = (errors, groupErrors, control) => { if (PASSWORD_FIELDS.indexOf(String(control.name)) < 0) return errors; @@ -35,8 +34,7 @@ export class ResetPasswordComponent implements OnInit { ) {} ngOnInit(): void { - this.route.queryParams.subscribe(({ userId, resetToken, tenantId }) => { - this.tenantId = tenantId; + this.route.queryParams.subscribe(({ userId, resetToken }) => { if (!userId || !resetToken) this.router.navigateByUrl('/account/login'); this.form = this.fb.group( @@ -63,7 +61,6 @@ export class ResetPasswordComponent implements OnInit { userId: this.form.get('userId').value, resetToken: this.form.get('resetToken').value, password: this.form.get('password').value, - tenantId: this.tenantId || undefined, // if this.tenantId is empty, we should not send it at all }) .pipe(finalize(() => (this.inProgress = false))) .subscribe(() => { diff --git a/npm/ng-packs/packages/account/src/lib/proxy/account/models.ts b/npm/ng-packs/packages/account/src/lib/proxy/account/models.ts index 0c4fe0c03d..f186b52977 100644 --- a/npm/ng-packs/packages/account/src/lib/proxy/account/models.ts +++ b/npm/ng-packs/packages/account/src/lib/proxy/account/models.ts @@ -9,7 +9,6 @@ export interface RegisterDto extends ExtensibleObject { export interface ResetPasswordDto { userId?: string; - tenantId?: string; resetToken: string; password: string; } From c137353976095dd403d55ca490277d50e2a6fd81 Mon Sep 17 00:00:00 2001 From: bnymncoskuner Date: Mon, 12 Jul 2021 16:39:20 +0300 Subject: [PATCH 2/7] feat: run generate-proxy for account --- .../account/src/lib/proxy/generate-proxy.json | 1219 +++++++++-------- 1 file changed, 613 insertions(+), 606 deletions(-) diff --git a/npm/ng-packs/packages/account/src/lib/proxy/generate-proxy.json b/npm/ng-packs/packages/account/src/lib/proxy/generate-proxy.json index f9703aad8a..ff7a22c89b 100644 --- a/npm/ng-packs/packages/account/src/lib/proxy/generate-proxy.json +++ b/npm/ng-packs/packages/account/src/lib/proxy/generate-proxy.json @@ -3,99 +3,16 @@ "account" ], "modules": { - "abp": { - "rootPath": "abp", - "remoteServiceName": "abp", + "settingManagement": { + "rootPath": "settingManagement", + "remoteServiceName": "SettingManagement", "controllers": { - "Pages.Abp.MultiTenancy.AbpTenantController": { - "controllerName": "AbpTenant", - "type": "Pages.Abp.MultiTenancy.AbpTenantController", - "interfaces": [ - { - "type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.IAbpTenantAppService" - } - ], - "actions": { - "FindTenantByNameAsyncByName": { - "uniqueName": "FindTenantByNameAsyncByName", - "name": "FindTenantByNameAsync", - "httpMethod": "GET", - "url": "api/abp/multi-tenancy/tenants/by-name/{name}", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "name", - "typeAsString": "System.String, System.Private.CoreLib", - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "name", - "name": "name", - "jsonName": null, - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": [], - "bindingSourceId": "Path", - "descriptorName": "" - } - ], - "returnValue": { - "type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto", - "typeSimple": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto" - }, - "allowAnonymous": null - }, - "FindTenantByIdAsyncById": { - "uniqueName": "FindTenantByIdAsyncById", - "name": "FindTenantByIdAsync", - "httpMethod": "GET", - "url": "api/abp/multi-tenancy/tenants/by-id/{id}", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "id", - "typeAsString": "System.Guid, System.Private.CoreLib", - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "id", - "name": "id", - "jsonName": null, - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": [], - "bindingSourceId": "Path", - "descriptorName": "" - } - ], - "returnValue": { - "type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto", - "typeSimple": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto" - }, - "allowAnonymous": null - } - } - }, - "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController": { - "controllerName": "AbpApplicationConfiguration", - "type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController", + "Volo.Abp.SettingManagement.EmailSettingsController": { + "controllerName": "EmailSettings", + "type": "Volo.Abp.SettingManagement.EmailSettingsController", "interfaces": [ { - "type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.IAbpApplicationConfigurationAppService" + "type": "Volo.Abp.SettingManagement.IEmailSettingsAppService" } ], "actions": { @@ -103,56 +20,49 @@ "uniqueName": "GetAsync", "name": "GetAsync", "httpMethod": "GET", - "url": "api/abp/application-configuration", + "url": "api/setting-management/emailing", "supportedVersions": [], "parametersOnMethod": [], "parameters": [], "returnValue": { - "type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto", - "typeSimple": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto" + "type": "Volo.Abp.SettingManagement.EmailSettingsDto", + "typeSimple": "Volo.Abp.SettingManagement.EmailSettingsDto" }, "allowAnonymous": null - } - } - }, - "Volo.Abp.AspNetCore.Mvc.ApiExploring.AbpApiDefinitionController": { - "controllerName": "AbpApiDefinition", - "type": "Volo.Abp.AspNetCore.Mvc.ApiExploring.AbpApiDefinitionController", - "interfaces": [], - "actions": { - "GetByModel": { - "uniqueName": "GetByModel", - "name": "Get", - "httpMethod": "GET", - "url": "api/abp/api-definition", + }, + "UpdateAsyncByInput": { + "uniqueName": "UpdateAsyncByInput", + "name": "UpdateAsync", + "httpMethod": "POST", + "url": "api/setting-management/emailing", "supportedVersions": [], "parametersOnMethod": [ { - "name": "model", - "typeAsString": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto, Volo.Abp.Http", - "type": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto", - "typeSimple": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto", + "name": "input", + "typeAsString": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto, Volo.Abp.SettingManagement.Application.Contracts", + "type": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", + "typeSimple": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", "isOptional": false, "defaultValue": null } ], "parameters": [ { - "nameOnMethod": "model", - "name": "IncludeTypes", + "nameOnMethod": "input", + "name": "input", "jsonName": null, - "type": "System.Boolean", - "typeSimple": "boolean", + "type": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", + "typeSimple": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", "isOptional": false, "defaultValue": null, "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "model" + "bindingSourceId": "Body", + "descriptorName": "" } ], "returnValue": { - "type": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModel", - "typeSimple": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModel" + "type": "System.Void", + "typeSimple": "System.Void" }, "allowAnonymous": null } @@ -160,308 +70,28 @@ } } }, - "multi-tenancy": { - "rootPath": "multi-tenancy", - "remoteServiceName": "AbpTenantManagement", + "abp": { + "rootPath": "abp", + "remoteServiceName": "abp", "controllers": { - "Volo.Abp.TenantManagement.TenantController": { - "controllerName": "Tenant", - "type": "Volo.Abp.TenantManagement.TenantController", + "Pages.Abp.MultiTenancy.AbpTenantController": { + "controllerName": "AbpTenant", + "type": "Pages.Abp.MultiTenancy.AbpTenantController", "interfaces": [ { - "type": "Volo.Abp.TenantManagement.ITenantAppService" + "type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.IAbpTenantAppService" } ], "actions": { - "GetAsyncById": { - "uniqueName": "GetAsyncById", - "name": "GetAsync", - "httpMethod": "GET", - "url": "api/multi-tenancy/tenants/{id}", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "id", - "typeAsString": "System.Guid, System.Private.CoreLib", - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "id", - "name": "id", - "jsonName": null, - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": [], - "bindingSourceId": "Path", - "descriptorName": "" - } - ], - "returnValue": { - "type": "Volo.Abp.TenantManagement.TenantDto", - "typeSimple": "Volo.Abp.TenantManagement.TenantDto" - }, - "allowAnonymous": null - }, - "GetListAsyncByInput": { - "uniqueName": "GetListAsyncByInput", - "name": "GetListAsync", - "httpMethod": "GET", - "url": "api/multi-tenancy/tenants", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "input", - "typeAsString": "Volo.Abp.TenantManagement.GetTenantsInput, Volo.Abp.TenantManagement.Application.Contracts", - "type": "Volo.Abp.TenantManagement.GetTenantsInput", - "typeSimple": "Volo.Abp.TenantManagement.GetTenantsInput", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "input", - "name": "Filter", - "jsonName": null, - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "input" - }, - { - "nameOnMethod": "input", - "name": "Sorting", - "jsonName": null, - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "input" - }, - { - "nameOnMethod": "input", - "name": "SkipCount", - "jsonName": null, - "type": "System.Int32", - "typeSimple": "number", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "input" - }, - { - "nameOnMethod": "input", - "name": "MaxResultCount", - "jsonName": null, - "type": "System.Int32", - "typeSimple": "number", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "input" - } - ], - "returnValue": { - "type": "Volo.Abp.Application.Dtos.PagedResultDto", - "typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto" - }, - "allowAnonymous": null - }, - "CreateAsyncByInput": { - "uniqueName": "CreateAsyncByInput", - "name": "CreateAsync", - "httpMethod": "POST", - "url": "api/multi-tenancy/tenants", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "input", - "typeAsString": "Volo.Abp.TenantManagement.TenantCreateDto, Volo.Abp.TenantManagement.Application.Contracts", - "type": "Volo.Abp.TenantManagement.TenantCreateDto", - "typeSimple": "Volo.Abp.TenantManagement.TenantCreateDto", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "input", - "name": "input", - "jsonName": null, - "type": "Volo.Abp.TenantManagement.TenantCreateDto", - "typeSimple": "Volo.Abp.TenantManagement.TenantCreateDto", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "Body", - "descriptorName": "" - } - ], - "returnValue": { - "type": "Volo.Abp.TenantManagement.TenantDto", - "typeSimple": "Volo.Abp.TenantManagement.TenantDto" - }, - "allowAnonymous": null - }, - "UpdateAsyncByIdAndInput": { - "uniqueName": "UpdateAsyncByIdAndInput", - "name": "UpdateAsync", - "httpMethod": "PUT", - "url": "api/multi-tenancy/tenants/{id}", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "id", - "typeAsString": "System.Guid, System.Private.CoreLib", - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - }, - { - "name": "input", - "typeAsString": "Volo.Abp.TenantManagement.TenantUpdateDto, Volo.Abp.TenantManagement.Application.Contracts", - "type": "Volo.Abp.TenantManagement.TenantUpdateDto", - "typeSimple": "Volo.Abp.TenantManagement.TenantUpdateDto", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "id", - "name": "id", - "jsonName": null, - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": [], - "bindingSourceId": "Path", - "descriptorName": "" - }, - { - "nameOnMethod": "input", - "name": "input", - "jsonName": null, - "type": "Volo.Abp.TenantManagement.TenantUpdateDto", - "typeSimple": "Volo.Abp.TenantManagement.TenantUpdateDto", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "Body", - "descriptorName": "" - } - ], - "returnValue": { - "type": "Volo.Abp.TenantManagement.TenantDto", - "typeSimple": "Volo.Abp.TenantManagement.TenantDto" - }, - "allowAnonymous": null - }, - "DeleteAsyncById": { - "uniqueName": "DeleteAsyncById", - "name": "DeleteAsync", - "httpMethod": "DELETE", - "url": "api/multi-tenancy/tenants/{id}", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "id", - "typeAsString": "System.Guid, System.Private.CoreLib", - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "id", - "name": "id", - "jsonName": null, - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": [], - "bindingSourceId": "Path", - "descriptorName": "" - } - ], - "returnValue": { - "type": "System.Void", - "typeSimple": "System.Void" - }, - "allowAnonymous": null - }, - "GetDefaultConnectionStringAsyncById": { - "uniqueName": "GetDefaultConnectionStringAsyncById", - "name": "GetDefaultConnectionStringAsync", - "httpMethod": "GET", - "url": "api/multi-tenancy/tenants/{id}/default-connection-string", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "id", - "typeAsString": "System.Guid, System.Private.CoreLib", - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "id", - "name": "id", - "jsonName": null, - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": [], - "bindingSourceId": "Path", - "descriptorName": "" - } - ], - "returnValue": { - "type": "System.String", - "typeSimple": "string" - }, - "allowAnonymous": null - }, - "UpdateDefaultConnectionStringAsyncByIdAndDefaultConnectionString": { - "uniqueName": "UpdateDefaultConnectionStringAsyncByIdAndDefaultConnectionString", - "name": "UpdateDefaultConnectionStringAsync", - "httpMethod": "PUT", - "url": "api/multi-tenancy/tenants/{id}/default-connection-string", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "id", - "typeAsString": "System.Guid, System.Private.CoreLib", - "type": "System.Guid", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - }, + "FindTenantByNameAsyncByName": { + "uniqueName": "FindTenantByNameAsyncByName", + "name": "FindTenantByNameAsync", + "httpMethod": "GET", + "url": "api/abp/multi-tenancy/tenants/by-name/{name}", + "supportedVersions": [], + "parametersOnMethod": [ { - "name": "defaultConnectionString", + "name": "name", "typeAsString": "System.String, System.Private.CoreLib", "type": "System.String", "typeSimple": "string", @@ -471,41 +101,29 @@ ], "parameters": [ { - "nameOnMethod": "id", - "name": "id", + "nameOnMethod": "name", + "name": "name", "jsonName": null, - "type": "System.Guid", + "type": "System.String", "typeSimple": "string", "isOptional": false, "defaultValue": null, "constraintTypes": [], "bindingSourceId": "Path", "descriptorName": "" - }, - { - "nameOnMethod": "defaultConnectionString", - "name": "defaultConnectionString", - "jsonName": null, - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "" } ], "returnValue": { - "type": "System.Void", - "typeSimple": "System.Void" + "type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto", + "typeSimple": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto" }, "allowAnonymous": null }, - "DeleteDefaultConnectionStringAsyncById": { - "uniqueName": "DeleteDefaultConnectionStringAsyncById", - "name": "DeleteDefaultConnectionStringAsync", - "httpMethod": "DELETE", - "url": "api/multi-tenancy/tenants/{id}/default-connection-string", + "FindTenantByIdAsyncById": { + "uniqueName": "FindTenantByIdAsyncById", + "name": "FindTenantByIdAsync", + "httpMethod": "GET", + "url": "api/abp/multi-tenancy/tenants/by-id/{id}", "supportedVersions": [], "parametersOnMethod": [ { @@ -532,25 +150,19 @@ } ], "returnValue": { - "type": "System.Void", - "typeSimple": "System.Void" + "type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto", + "typeSimple": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto" }, "allowAnonymous": null } } - } - } - }, - "settingManagement": { - "rootPath": "settingManagement", - "remoteServiceName": "SettingManagement", - "controllers": { - "Volo.Abp.SettingManagement.EmailSettingsController": { - "controllerName": "EmailSettings", - "type": "Volo.Abp.SettingManagement.EmailSettingsController", + }, + "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController": { + "controllerName": "AbpApplicationConfiguration", + "type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController", "interfaces": [ { - "type": "Volo.Abp.SettingManagement.IEmailSettingsAppService" + "type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.IAbpApplicationConfigurationAppService" } ], "actions": { @@ -558,49 +170,56 @@ "uniqueName": "GetAsync", "name": "GetAsync", "httpMethod": "GET", - "url": "api/setting-management/emailing", + "url": "api/abp/application-configuration", "supportedVersions": [], "parametersOnMethod": [], "parameters": [], "returnValue": { - "type": "Volo.Abp.SettingManagement.EmailSettingsDto", - "typeSimple": "Volo.Abp.SettingManagement.EmailSettingsDto" + "type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto", + "typeSimple": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto" }, "allowAnonymous": null - }, - "UpdateAsyncByInput": { - "uniqueName": "UpdateAsyncByInput", - "name": "UpdateAsync", - "httpMethod": "POST", - "url": "api/setting-management/emailing", + } + } + }, + "Volo.Abp.AspNetCore.Mvc.ApiExploring.AbpApiDefinitionController": { + "controllerName": "AbpApiDefinition", + "type": "Volo.Abp.AspNetCore.Mvc.ApiExploring.AbpApiDefinitionController", + "interfaces": [], + "actions": { + "GetByModel": { + "uniqueName": "GetByModel", + "name": "Get", + "httpMethod": "GET", + "url": "api/abp/api-definition", "supportedVersions": [], "parametersOnMethod": [ { - "name": "input", - "typeAsString": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto, Volo.Abp.SettingManagement.Application.Contracts", - "type": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", - "typeSimple": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", + "name": "model", + "typeAsString": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto, Volo.Abp.Http", + "type": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto", + "typeSimple": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto", "isOptional": false, "defaultValue": null } ], "parameters": [ { - "nameOnMethod": "input", - "name": "input", + "nameOnMethod": "model", + "name": "IncludeTypes", "jsonName": null, - "type": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", - "typeSimple": "Volo.Abp.SettingManagement.UpdateEmailSettingsDto", + "type": "System.Boolean", + "typeSimple": "boolean", "isOptional": false, "defaultValue": null, "constraintTypes": null, - "bindingSourceId": "Body", - "descriptorName": "" + "bindingSourceId": "ModelBinding", + "descriptorName": "model" } ], "returnValue": { - "type": "System.Void", - "typeSimple": "System.Void" + "type": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModel", + "typeSimple": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModel" }, "allowAnonymous": null } @@ -807,8 +426,157 @@ "nameOnMethod": "input", "name": "input", "jsonName": null, - "type": "Volo.Abp.Account.ResetPasswordDto", - "typeSimple": "Volo.Abp.Account.ResetPasswordDto", + "type": "Volo.Abp.Account.ResetPasswordDto", + "typeSimple": "Volo.Abp.Account.ResetPasswordDto", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "Body", + "descriptorName": "" + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + }, + "allowAnonymous": null + } + } + } + } + }, + "permissionManagement": { + "rootPath": "permissionManagement", + "remoteServiceName": "AbpPermissionManagement", + "controllers": { + "Volo.Abp.PermissionManagement.PermissionsController": { + "controllerName": "Permissions", + "type": "Volo.Abp.PermissionManagement.PermissionsController", + "interfaces": [ + { + "type": "Volo.Abp.PermissionManagement.IPermissionAppService" + } + ], + "actions": { + "GetAsyncByProviderNameAndProviderKey": { + "uniqueName": "GetAsyncByProviderNameAndProviderKey", + "name": "GetAsync", + "httpMethod": "GET", + "url": "api/permission-management/permissions", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "providerName", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + }, + { + "name": "providerKey", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "providerName", + "name": "providerName", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + }, + { + "nameOnMethod": "providerKey", + "name": "providerKey", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + } + ], + "returnValue": { + "type": "Volo.Abp.PermissionManagement.GetPermissionListResultDto", + "typeSimple": "Volo.Abp.PermissionManagement.GetPermissionListResultDto" + }, + "allowAnonymous": null + }, + "UpdateAsyncByProviderNameAndProviderKeyAndInput": { + "uniqueName": "UpdateAsyncByProviderNameAndProviderKeyAndInput", + "name": "UpdateAsync", + "httpMethod": "PUT", + "url": "api/permission-management/permissions", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "providerName", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + }, + { + "name": "providerKey", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + }, + { + "name": "input", + "typeAsString": "Volo.Abp.PermissionManagement.UpdatePermissionsDto, Volo.Abp.PermissionManagement.Application.Contracts", + "type": "Volo.Abp.PermissionManagement.UpdatePermissionsDto", + "typeSimple": "Volo.Abp.PermissionManagement.UpdatePermissionsDto", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "providerName", + "name": "providerName", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + }, + { + "nameOnMethod": "providerKey", + "name": "providerKey", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + }, + { + "nameOnMethod": "input", + "name": "input", + "jsonName": null, + "type": "Volo.Abp.PermissionManagement.UpdatePermissionsDto", + "typeSimple": "Volo.Abp.PermissionManagement.UpdatePermissionsDto", "isOptional": false, "defaultValue": null, "constraintTypes": null, @@ -1806,16 +1574,16 @@ } } }, - "permissionManagement": { - "rootPath": "permissionManagement", - "remoteServiceName": "AbpPermissionManagement", + "featureManagement": { + "rootPath": "featureManagement", + "remoteServiceName": "AbpFeatureManagement", "controllers": { - "Volo.Abp.PermissionManagement.PermissionsController": { - "controllerName": "Permissions", - "type": "Volo.Abp.PermissionManagement.PermissionsController", + "Volo.Abp.FeatureManagement.FeaturesController": { + "controllerName": "Features", + "type": "Volo.Abp.FeatureManagement.FeaturesController", "interfaces": [ { - "type": "Volo.Abp.PermissionManagement.IPermissionAppService" + "type": "Volo.Abp.FeatureManagement.IFeatureAppService" } ], "actions": { @@ -1823,7 +1591,63 @@ "uniqueName": "GetAsyncByProviderNameAndProviderKey", "name": "GetAsync", "httpMethod": "GET", - "url": "api/permission-management/permissions", + "url": "api/feature-management/features", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "providerName", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + }, + { + "name": "providerKey", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "providerName", + "name": "providerName", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + }, + { + "nameOnMethod": "providerKey", + "name": "providerKey", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + } + ], + "returnValue": { + "type": "Volo.Abp.FeatureManagement.GetFeatureListResultDto", + "typeSimple": "Volo.Abp.FeatureManagement.GetFeatureListResultDto" + }, + "allowAnonymous": null + }, + "UpdateAsyncByProviderNameAndProviderKeyAndInput": { + "uniqueName": "UpdateAsyncByProviderNameAndProviderKeyAndInput", + "name": "UpdateAsync", + "httpMethod": "PUT", + "url": "api/feature-management/features", "supportedVersions": [], "parametersOnMethod": [ { @@ -1841,6 +1665,14 @@ "typeSimple": "string", "isOptional": false, "defaultValue": null + }, + { + "name": "input", + "typeAsString": "Volo.Abp.FeatureManagement.UpdateFeaturesDto, Volo.Abp.FeatureManagement.Application.Contracts", + "type": "Volo.Abp.FeatureManagement.UpdateFeaturesDto", + "typeSimple": "Volo.Abp.FeatureManagement.UpdateFeaturesDto", + "isOptional": false, + "defaultValue": null } ], "parameters": [ @@ -1860,84 +1692,237 @@ "nameOnMethod": "providerKey", "name": "providerKey", "jsonName": null, - "type": "System.String", - "typeSimple": "string", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "" + }, + { + "nameOnMethod": "input", + "name": "input", + "jsonName": null, + "type": "Volo.Abp.FeatureManagement.UpdateFeaturesDto", + "typeSimple": "Volo.Abp.FeatureManagement.UpdateFeaturesDto", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "Body", + "descriptorName": "" + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + }, + "allowAnonymous": null + } + } + } + } + }, + "multi-tenancy": { + "rootPath": "multi-tenancy", + "remoteServiceName": "AbpTenantManagement", + "controllers": { + "Volo.Abp.TenantManagement.TenantController": { + "controllerName": "Tenant", + "type": "Volo.Abp.TenantManagement.TenantController", + "interfaces": [ + { + "type": "Volo.Abp.TenantManagement.ITenantAppService" + } + ], + "actions": { + "GetAsyncById": { + "uniqueName": "GetAsyncById", + "name": "GetAsync", + "httpMethod": "GET", + "url": "api/multi-tenancy/tenants/{id}", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "id", + "typeAsString": "System.Guid, System.Private.CoreLib", + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "id", + "name": "id", + "jsonName": null, + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": [], + "bindingSourceId": "Path", + "descriptorName": "" + } + ], + "returnValue": { + "type": "Volo.Abp.TenantManagement.TenantDto", + "typeSimple": "Volo.Abp.TenantManagement.TenantDto" + }, + "allowAnonymous": null + }, + "GetListAsyncByInput": { + "uniqueName": "GetListAsyncByInput", + "name": "GetListAsync", + "httpMethod": "GET", + "url": "api/multi-tenancy/tenants", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Abp.TenantManagement.GetTenantsInput, Volo.Abp.TenantManagement.Application.Contracts", + "type": "Volo.Abp.TenantManagement.GetTenantsInput", + "typeSimple": "Volo.Abp.TenantManagement.GetTenantsInput", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "Filter", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Sorting", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "SkipCount", + "jsonName": null, + "type": "System.Int32", + "typeSimple": "number", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "MaxResultCount", + "jsonName": null, + "type": "System.Int32", + "typeSimple": "number", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + } + ], + "returnValue": { + "type": "Volo.Abp.Application.Dtos.PagedResultDto", + "typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto" + }, + "allowAnonymous": null + }, + "CreateAsyncByInput": { + "uniqueName": "CreateAsyncByInput", + "name": "CreateAsync", + "httpMethod": "POST", + "url": "api/multi-tenancy/tenants", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Abp.TenantManagement.TenantCreateDto, Volo.Abp.TenantManagement.Application.Contracts", + "type": "Volo.Abp.TenantManagement.TenantCreateDto", + "typeSimple": "Volo.Abp.TenantManagement.TenantCreateDto", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "input", + "jsonName": null, + "type": "Volo.Abp.TenantManagement.TenantCreateDto", + "typeSimple": "Volo.Abp.TenantManagement.TenantCreateDto", "isOptional": false, "defaultValue": null, "constraintTypes": null, - "bindingSourceId": "ModelBinding", + "bindingSourceId": "Body", "descriptorName": "" } ], "returnValue": { - "type": "Volo.Abp.PermissionManagement.GetPermissionListResultDto", - "typeSimple": "Volo.Abp.PermissionManagement.GetPermissionListResultDto" + "type": "Volo.Abp.TenantManagement.TenantDto", + "typeSimple": "Volo.Abp.TenantManagement.TenantDto" }, "allowAnonymous": null }, - "UpdateAsyncByProviderNameAndProviderKeyAndInput": { - "uniqueName": "UpdateAsyncByProviderNameAndProviderKeyAndInput", + "UpdateAsyncByIdAndInput": { + "uniqueName": "UpdateAsyncByIdAndInput", "name": "UpdateAsync", "httpMethod": "PUT", - "url": "api/permission-management/permissions", + "url": "api/multi-tenancy/tenants/{id}", "supportedVersions": [], "parametersOnMethod": [ { - "name": "providerName", - "typeAsString": "System.String, System.Private.CoreLib", - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - }, - { - "name": "providerKey", - "typeAsString": "System.String, System.Private.CoreLib", - "type": "System.String", + "name": "id", + "typeAsString": "System.Guid, System.Private.CoreLib", + "type": "System.Guid", "typeSimple": "string", "isOptional": false, "defaultValue": null }, { "name": "input", - "typeAsString": "Volo.Abp.PermissionManagement.UpdatePermissionsDto, Volo.Abp.PermissionManagement.Application.Contracts", - "type": "Volo.Abp.PermissionManagement.UpdatePermissionsDto", - "typeSimple": "Volo.Abp.PermissionManagement.UpdatePermissionsDto", + "typeAsString": "Volo.Abp.TenantManagement.TenantUpdateDto, Volo.Abp.TenantManagement.Application.Contracts", + "type": "Volo.Abp.TenantManagement.TenantUpdateDto", + "typeSimple": "Volo.Abp.TenantManagement.TenantUpdateDto", "isOptional": false, "defaultValue": null } ], "parameters": [ { - "nameOnMethod": "providerName", - "name": "providerName", - "jsonName": null, - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "" - }, - { - "nameOnMethod": "providerKey", - "name": "providerKey", + "nameOnMethod": "id", + "name": "id", "jsonName": null, - "type": "System.String", + "type": "System.Guid", "typeSimple": "string", "isOptional": false, "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", + "constraintTypes": [], + "bindingSourceId": "Path", "descriptorName": "" }, { "nameOnMethod": "input", "name": "input", "jsonName": null, - "type": "Volo.Abp.PermissionManagement.UpdatePermissionsDto", - "typeSimple": "Volo.Abp.PermissionManagement.UpdatePermissionsDto", + "type": "Volo.Abp.TenantManagement.TenantUpdateDto", + "typeSimple": "Volo.Abp.TenantManagement.TenantUpdateDto", "isOptional": false, "defaultValue": null, "constraintTypes": null, @@ -1946,47 +1931,22 @@ } ], "returnValue": { - "type": "System.Void", - "typeSimple": "System.Void" + "type": "Volo.Abp.TenantManagement.TenantDto", + "typeSimple": "Volo.Abp.TenantManagement.TenantDto" }, "allowAnonymous": null - } - } - } - } - }, - "featureManagement": { - "rootPath": "featureManagement", - "remoteServiceName": "AbpFeatureManagement", - "controllers": { - "Volo.Abp.FeatureManagement.FeaturesController": { - "controllerName": "Features", - "type": "Volo.Abp.FeatureManagement.FeaturesController", - "interfaces": [ - { - "type": "Volo.Abp.FeatureManagement.IFeatureAppService" - } - ], - "actions": { - "GetAsyncByProviderNameAndProviderKey": { - "uniqueName": "GetAsyncByProviderNameAndProviderKey", - "name": "GetAsync", - "httpMethod": "GET", - "url": "api/feature-management/features", + }, + "DeleteAsyncById": { + "uniqueName": "DeleteAsyncById", + "name": "DeleteAsync", + "httpMethod": "DELETE", + "url": "api/multi-tenancy/tenants/{id}", "supportedVersions": [], "parametersOnMethod": [ { - "name": "providerName", - "typeAsString": "System.String, System.Private.CoreLib", - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null - }, - { - "name": "providerKey", - "typeAsString": "System.String, System.Private.CoreLib", - "type": "System.String", + "name": "id", + "typeAsString": "System.Guid, System.Private.CoreLib", + "type": "System.Guid", "typeSimple": "string", "isOptional": false, "defaultValue": null @@ -1994,84 +1954,100 @@ ], "parameters": [ { - "nameOnMethod": "providerName", - "name": "providerName", + "nameOnMethod": "id", + "name": "id", "jsonName": null, - "type": "System.String", + "type": "System.Guid", "typeSimple": "string", "isOptional": false, "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", + "constraintTypes": [], + "bindingSourceId": "Path", "descriptorName": "" - }, + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + }, + "allowAnonymous": null + }, + "GetDefaultConnectionStringAsyncById": { + "uniqueName": "GetDefaultConnectionStringAsyncById", + "name": "GetDefaultConnectionStringAsync", + "httpMethod": "GET", + "url": "api/multi-tenancy/tenants/{id}/default-connection-string", + "supportedVersions": [], + "parametersOnMethod": [ { - "nameOnMethod": "providerKey", - "name": "providerKey", + "name": "id", + "typeAsString": "System.Guid, System.Private.CoreLib", + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "id", + "name": "id", "jsonName": null, - "type": "System.String", + "type": "System.Guid", "typeSimple": "string", "isOptional": false, "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", + "constraintTypes": [], + "bindingSourceId": "Path", "descriptorName": "" } ], "returnValue": { - "type": "Volo.Abp.FeatureManagement.GetFeatureListResultDto", - "typeSimple": "Volo.Abp.FeatureManagement.GetFeatureListResultDto" + "type": "System.String", + "typeSimple": "string" }, "allowAnonymous": null }, - "UpdateAsyncByProviderNameAndProviderKeyAndInput": { - "uniqueName": "UpdateAsyncByProviderNameAndProviderKeyAndInput", - "name": "UpdateAsync", + "UpdateDefaultConnectionStringAsyncByIdAndDefaultConnectionString": { + "uniqueName": "UpdateDefaultConnectionStringAsyncByIdAndDefaultConnectionString", + "name": "UpdateDefaultConnectionStringAsync", "httpMethod": "PUT", - "url": "api/feature-management/features", + "url": "api/multi-tenancy/tenants/{id}/default-connection-string", "supportedVersions": [], "parametersOnMethod": [ { - "name": "providerName", - "typeAsString": "System.String, System.Private.CoreLib", - "type": "System.String", + "name": "id", + "typeAsString": "System.Guid, System.Private.CoreLib", + "type": "System.Guid", "typeSimple": "string", "isOptional": false, "defaultValue": null }, { - "name": "providerKey", + "name": "defaultConnectionString", "typeAsString": "System.String, System.Private.CoreLib", "type": "System.String", "typeSimple": "string", "isOptional": false, "defaultValue": null - }, - { - "name": "input", - "typeAsString": "Volo.Abp.FeatureManagement.UpdateFeaturesDto, Volo.Abp.FeatureManagement.Application.Contracts", - "type": "Volo.Abp.FeatureManagement.UpdateFeaturesDto", - "typeSimple": "Volo.Abp.FeatureManagement.UpdateFeaturesDto", - "isOptional": false, - "defaultValue": null } ], "parameters": [ { - "nameOnMethod": "providerName", - "name": "providerName", + "nameOnMethod": "id", + "name": "id", "jsonName": null, - "type": "System.String", + "type": "System.Guid", "typeSimple": "string", "isOptional": false, "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", + "constraintTypes": [], + "bindingSourceId": "Path", "descriptorName": "" }, { - "nameOnMethod": "providerKey", - "name": "providerKey", + "nameOnMethod": "defaultConnectionString", + "name": "defaultConnectionString", "jsonName": null, "type": "System.String", "typeSimple": "string", @@ -2080,17 +2056,41 @@ "constraintTypes": null, "bindingSourceId": "ModelBinding", "descriptorName": "" - }, + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + }, + "allowAnonymous": null + }, + "DeleteDefaultConnectionStringAsyncById": { + "uniqueName": "DeleteDefaultConnectionStringAsyncById", + "name": "DeleteDefaultConnectionStringAsync", + "httpMethod": "DELETE", + "url": "api/multi-tenancy/tenants/{id}/default-connection-string", + "supportedVersions": [], + "parametersOnMethod": [ { - "nameOnMethod": "input", - "name": "input", + "name": "id", + "typeAsString": "System.Guid, System.Private.CoreLib", + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "id", + "name": "id", "jsonName": null, - "type": "Volo.Abp.FeatureManagement.UpdateFeaturesDto", - "typeSimple": "Volo.Abp.FeatureManagement.UpdateFeaturesDto", + "type": "System.Guid", + "typeSimple": "string", "isOptional": false, "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "Body", + "constraintTypes": [], + "bindingSourceId": "Path", "descriptorName": "" } ], @@ -2469,13 +2469,6 @@ "typeSimple": "string", "isRequired": false }, - { - "name": "TenantId", - "jsonName": null, - "type": "System.Guid?", - "typeSimple": "string?", - "isRequired": false - }, { "name": "ResetToken", "jsonName": null, @@ -4125,6 +4118,20 @@ "typeSimple": "string?", "isRequired": false }, + { + "name": "ImpersonatorUserId", + "jsonName": null, + "type": "System.Guid?", + "typeSimple": "string?", + "isRequired": false + }, + { + "name": "ImpersonatorTenantId", + "jsonName": null, + "type": "System.Guid?", + "typeSimple": "string?", + "isRequired": false + }, { "name": "UserName", "jsonName": null, From 553a9578e0094c2265401f726d29ccd4752dd258 Mon Sep 17 00:00:00 2001 From: bnymncoskuner Date: Mon, 12 Jul 2021 18:47:12 +0300 Subject: [PATCH 3/7] feat: add token for tenant key and resolve it from url --- .../packages/core/src/lib/core.module.ts | 2 + .../src/lib/interceptors/api.interceptor.ts | 8 +-- .../packages/core/src/lib/models/common.ts | 6 +-- .../abp/multi-tenancy/abp-tenant.service.ts | 3 +- .../src/lib/services/config-state.service.ts | 9 +++- .../src/lib/services/multi-tenancy.service.ts | 47 ++++++++++------- .../src/lib/strategies/auth-flow.strategy.ts | 5 +- .../packages/core/src/lib/tokens/index.ts | 1 + .../core/src/lib/tokens/tenant-key.token.ts | 3 ++ .../core/src/lib/utils/multi-tenancy-utils.ts | 51 ++++++++++++------- 10 files changed, 90 insertions(+), 45 deletions(-) create mode 100644 npm/ng-packs/packages/core/src/lib/tokens/tenant-key.token.ts diff --git a/npm/ng-packs/packages/core/src/lib/core.module.ts b/npm/ng-packs/packages/core/src/lib/core.module.ts index 986cb98f3b..5f986789f3 100644 --- a/npm/ng-packs/packages/core/src/lib/core.module.ts +++ b/npm/ng-packs/packages/core/src/lib/core.module.ts @@ -33,6 +33,7 @@ import { coreOptionsFactory, CORE_OPTIONS } from './tokens/options.token'; import { noop } from './utils/common-utils'; import './utils/date-extensions'; import { getInitialData, localeInitializer } from './utils/initial-utils'; +import { TENANT_KEY } from './tokens/tenant-key.token'; export function storageFactory(): OAuthStorage { return oAuthStorage; @@ -178,6 +179,7 @@ export class CoreModule { useFactory: noop, }, { provide: OAuthStorage, useFactory: storageFactory }, + { provide: TENANT_KEY, useValue: options.tenantKey || '__tenant' }, ], }; } diff --git a/npm/ng-packs/packages/core/src/lib/interceptors/api.interceptor.ts b/npm/ng-packs/packages/core/src/lib/interceptors/api.interceptor.ts index ad60178a98..da73b1ba55 100644 --- a/npm/ng-packs/packages/core/src/lib/interceptors/api.interceptor.ts +++ b/npm/ng-packs/packages/core/src/lib/interceptors/api.interceptor.ts @@ -1,9 +1,10 @@ import { HttpHandler, HttpHeaders, HttpInterceptor, HttpRequest } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, Inject } from '@angular/core'; import { OAuthService } from 'angular-oauth2-oidc'; import { finalize } from 'rxjs/operators'; import { SessionStateService } from '../services/session-state.service'; import { HttpWaitService } from '../services/http-wait.service'; +import { TENANT_KEY } from '../tokens/tenant-key.token'; @Injectable({ providedIn: 'root', @@ -13,6 +14,7 @@ export class ApiInterceptor implements HttpInterceptor { private oAuthService: OAuthService, private sessionState: SessionStateService, private httpWaitService: HttpWaitService, + @Inject(TENANT_KEY) private tenantKey: string, ) {} intercept(request: HttpRequest, next: HttpHandler) { @@ -40,8 +42,8 @@ export class ApiInterceptor implements HttpInterceptor { } const tenant = this.sessionState.getTenant(); - if (!existingHeaders?.has('__tenant') && tenant?.id) { - headers['__tenant'] = tenant.id; + if (!existingHeaders?.has(this.tenantKey) && tenant?.id) { + headers[this.tenantKey] = tenant.id; } return headers; diff --git a/npm/ng-packs/packages/core/src/lib/models/common.ts b/npm/ng-packs/packages/core/src/lib/models/common.ts index db03b1cea7..d99d591ad4 100644 --- a/npm/ng-packs/packages/core/src/lib/models/common.ts +++ b/npm/ng-packs/packages/core/src/lib/models/common.ts @@ -10,6 +10,7 @@ export namespace ABP { registerLocaleFn: (locale: string) => Promise; skipGetAppConfiguration?: boolean; sendNullsAsQueryParam?: boolean; + tenantKey?: string; } export interface HasPolicy { @@ -74,7 +75,6 @@ export namespace ABP { [key: string]: T; } - export type ExtractFromOutput< - T extends EventEmitter | Subject - > = T extends EventEmitter ? X : T extends Subject ? Y : never; + export type ExtractFromOutput | Subject> = + T extends EventEmitter ? X : T extends Subject ? Y : never; } diff --git a/npm/ng-packs/packages/core/src/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.ts b/npm/ng-packs/packages/core/src/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.ts index a1c4d4bb9b..99aa704ed1 100644 --- a/npm/ng-packs/packages/core/src/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.ts +++ b/npm/ng-packs/packages/core/src/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.ts @@ -8,11 +8,12 @@ import type { FindTenantResultDto } from '../../../volo/abp/asp-net-core/mvc/mul export class AbpTenantService { apiName = 'abp'; - findTenantById = (id: string) => + findTenantById = (id: string, headers: Record) => this.restService.request( { method: 'GET', url: `/api/abp/multi-tenancy/tenants/by-id/${id}`, + headers, }, { apiName: this.apiName }, ); diff --git a/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts b/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts index 0ab66059a8..eb2a0d30b6 100644 --- a/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts @@ -1,8 +1,9 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; +import { map, tap } from 'rxjs/operators'; import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models'; import { InternalStore } from '../utils/internal-store-utils'; +import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service'; @Injectable({ providedIn: 'root', @@ -14,10 +15,16 @@ export class ConfigStateService { return this.store.sliceUpdate; } + constructor(private abpConfigService: AbpApplicationConfigurationService) {} + setState(state: ApplicationConfigurationDto) { this.store.set(state); } + refreshAppState() { + return this.abpConfigService.get().pipe(tap(res => this.setState(res))); + } + getOne$(key: string) { return this.store.sliceState(state => state[key]); } diff --git a/npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts b/npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts index 3789eb0847..7724106cfe 100644 --- a/npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts @@ -1,31 +1,32 @@ -import { Injectable } from '@angular/core'; +import { Injectable, Inject } from '@angular/core'; +import { switchMap, map } from 'rxjs/operators'; import { Observable } from 'rxjs'; import { ABP } from '../models/common'; -import { - CurrentTenantDto, - FindTenantResultDto, -} from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models'; +import { FindTenantResultDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models'; import { RestService } from './rest.service'; +import { AbpTenantService } from '../proxy/pages/abp/multi-tenancy'; +import { ConfigStateService } from './config-state.service'; import { SessionStateService } from './session-state.service'; +import { TENANT_KEY } from '../tokens/tenant-key.token'; @Injectable({ providedIn: 'root' }) export class MultiTenancyService { - private _domainTenant: CurrentTenantDto = null; - - set domainTenant(value: CurrentTenantDto) { - this._domainTenant = value; - this.sessionState.setTenant(value); - } - - get domainTenant() { - return this._domainTenant; - } - isTenantBoxVisible = true; apiName = 'abp'; - constructor(private restService: RestService, private sessionState: SessionStateService) {} + private setTenantToState = (tenant: FindTenantResultDto) => { + this.sessionState.setTenant({ id: tenant.tenantId, name: tenant.name, isAvailable: true }); + return this.configStateService.refreshAppState().pipe(map(_ => tenant)); + }; + + constructor( + private restService: RestService, + private sessionState: SessionStateService, + private tenantService: AbpTenantService, + private configStateService: ConfigStateService, + @Inject(TENANT_KEY) public tenantKey: string, + ) {} /** * @deprecated Use AbpTenantService.findTenantByName method instead. To be deleted in v5.0. @@ -50,4 +51,16 @@ export class MultiTenancyService { { apiName: this.apiName }, ); } + + setTenantByName(tenantName: string) { + return this.tenantService + .findTenantByName(tenantName, { [this.tenantKey]: '' }) + .pipe(switchMap(this.setTenantToState)); + } + + setTenantById(tenantId: string) { + return this.tenantService + .findTenantById(tenantId, { [this.tenantKey]: '' }) + .pipe(switchMap(this.setTenantToState)); + } } diff --git a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts index b9de17bf50..4cb959ac45 100644 --- a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts +++ b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts @@ -19,6 +19,7 @@ import { EnvironmentService } from '../services/environment.service'; import { SessionStateService } from '../services/session-state.service'; import { removeRememberMe, setRememberMe } from '../utils/auth-utils'; import { noop } from '../utils/common-utils'; +import { TENANT_KEY } from '../tokens/tenant-key.token'; export const oAuthStorage = localStorage; @@ -32,6 +33,7 @@ export abstract class AuthFlowStrategy { protected oAuthConfig: AuthConfig; protected sessionState: SessionStateService; protected appConfigService: AbpApplicationConfigurationService; + protected tenantKey: string; abstract checkIfInternalAuth(queryParams?: Params): boolean; abstract navigateToLogin(queryParams?: Params): void; @@ -48,6 +50,7 @@ export abstract class AuthFlowStrategy { this.appConfigService = injector.get(AbpApplicationConfigurationService); this.sessionState = injector.get(SessionStateService); this.oAuthConfig = this.environment.getEnvironment().oAuthConfig; + this.tenantKey = injector.get(TENANT_KEY); this.listenToOauthErrors(); } @@ -176,7 +179,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy { this.oAuthService.fetchTokenUsingPasswordFlow( params.username, params.password, - new HttpHeaders({ ...(tenant && tenant.id && { __tenant: tenant.id }) }), + new HttpHeaders({ ...(tenant && tenant.id && { [this.tenantKey]: tenant.id }) }), ), ).pipe(this.pipeToLogin(params)); } diff --git a/npm/ng-packs/packages/core/src/lib/tokens/index.ts b/npm/ng-packs/packages/core/src/lib/tokens/index.ts index c40fbc1bc0..4d102ee8b4 100644 --- a/npm/ng-packs/packages/core/src/lib/tokens/index.ts +++ b/npm/ng-packs/packages/core/src/lib/tokens/index.ts @@ -3,3 +3,4 @@ export * from './lodaer-delay.token'; export * from './manage-profile.token'; export * from './options.token'; export * from './app-config.token'; +export * from './tenant-key.token'; diff --git a/npm/ng-packs/packages/core/src/lib/tokens/tenant-key.token.ts b/npm/ng-packs/packages/core/src/lib/tokens/tenant-key.token.ts new file mode 100644 index 0000000000..1999b3b9f7 --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/tokens/tenant-key.token.ts @@ -0,0 +1,3 @@ +import { InjectionToken } from '@angular/core'; + +export const TENANT_KEY = new InjectionToken('TENANT_KEY'); diff --git a/npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts index dbcb2c8517..87e4d68c9e 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts @@ -1,10 +1,10 @@ import { Injector } from '@angular/core'; import clone from 'just-clone'; -import { of } from 'rxjs'; -import { switchMap, tap } from 'rxjs/operators'; + +import { tap } from 'rxjs/operators'; import { Environment } from '../models/environment'; -import { AbpTenantService } from '../proxy/pages/abp/multi-tenancy/abp-tenant.service'; -import { CurrentTenantDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models'; + +import { FindTenantResultDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models'; import { EnvironmentService } from '../services/environment.service'; import { MultiTenancyService } from '../services/multi-tenancy.service'; import { createTokenParser } from './string-utils'; @@ -19,39 +19,52 @@ function getCurrentTenancyName(appBaseUrl: string): string { return parseTokens(window.location.href)[token]?.[0]; } +function getCurrentTenancyNameFromUrl(tenantKey: string) { + const urlParams = new URLSearchParams(window.location.search); + return urlParams.get(tenantKey); +} + export async function parseTenantFromUrl(injector: Injector) { const environmentService = injector.get(EnvironmentService); const multiTenancyService = injector.get(MultiTenancyService); - const abpTenantService = injector.get(AbpTenantService); const baseUrl = environmentService.getEnvironment()?.application?.baseUrl || ''; const tenancyName = getCurrentTenancyName(baseUrl); - if (tenancyName) { + const hideTenantBox = () => { multiTenancyService.isTenantBoxVisible = false; - setEnvironment(injector, tenancyName); - - return of(null) - .pipe( - switchMap(() => abpTenantService.findTenantByName(tenancyName, { __tenant: '' })), - tap(res => { - multiTenancyService.domainTenant = res.success - ? ({ id: res.tenantId, name: res.name } as CurrentTenantDto) - : null; - }), - ) + }; + + const setEnvironmentWithTenant = (tenant: FindTenantResultDto) => { + hideTenantBox(); + replaceTenantNameWithinEnvironment(injector, tenant.name); + }; + + if (tenancyName) { + return multiTenancyService + .setTenantByName(tenancyName) + .pipe(tap(setEnvironmentWithTenant)) .toPromise(); } else { /** * If there is no tenant, we still have to clean up {0}. from baseUrl to avoid incorrect http requests. */ - setEnvironment(injector, '', tenancyPlaceholder + '.'); + replaceTenantNameWithinEnvironment(injector, '', tenancyPlaceholder + '.'); + + const tenantIdFromQueryParams = getCurrentTenancyNameFromUrl(multiTenancyService.tenantKey); + if (tenantIdFromQueryParams) { + return multiTenancyService.setTenantById(tenantIdFromQueryParams).toPromise(); + } } return Promise.resolve(); } -function setEnvironment(injector: Injector, tenancyName: string, placeholder = tenancyPlaceholder) { +function replaceTenantNameWithinEnvironment( + injector: Injector, + tenancyName: string, + placeholder = tenancyPlaceholder, +) { const environmentService = injector.get(EnvironmentService); const environment = clone(environmentService.getEnvironment()) as Environment; From 8d8917870781bb0ced3e00bb64f3af7ffe30e4bf Mon Sep 17 00:00:00 2001 From: bnymncoskuner Date: Mon, 12 Jul 2021 18:47:52 +0300 Subject: [PATCH 4/7] docs: update multi-tenancy docs with tenantKey in angular client --- docs/en/Multi-Tenancy.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/en/Multi-Tenancy.md b/docs/en/Multi-Tenancy.md index 5db646b7a7..f8098a4875 100644 --- a/docs/en/Multi-Tenancy.md +++ b/docs/en/Multi-Tenancy.md @@ -296,6 +296,32 @@ services.Configure(options => }); ```` +If you change the `TenantKey`, make sure to pass it to `CoreModule` in the Angular client as follows: + +```js +@NgModule({ + imports: [ + CoreModule.forRoot({ + // ... + tenantKey: 'MyTenantKey' + }), + ], + // ... +}) +export class AppModule {} +``` + +If you need to access it, you can inject it as follows: + +```js +import { Inject } from '@angular/core'; +import { TENANT_KEY } from '@abp/ng.core'; + +class SomeComponent { + constructor(@Inject(TENANT_KEY) private tenantKey: string) {} +} +``` + > However, we don't suggest to change this value since some clients may assume the the `__tenant` as the parameter name and they might need to manually configure then. ##### Domain/Subdomain Tenant Resolver From 79655e1fbe9b933d250e5c0f985e23839d050508 Mon Sep 17 00:00:00 2001 From: bnymncoskuner Date: Mon, 12 Jul 2021 18:48:40 +0300 Subject: [PATCH 5/7] fix: reading wrong data for tenantBoxVisible from route config --- .../src/lib/auth-wrapper.service.ts | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts b/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts index 44f53c7eef..7bad8ef96a 100644 --- a/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts +++ b/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts @@ -17,14 +17,12 @@ export class AuthWrapperService { tenantBoxKey = 'Account.TenantBoxComponent'; route: ActivatedRoute; - private _tenantBoxVisible = true; - - private setTenantBoxVisibility = () => { - this._tenantBoxVisible = this.route.snapshot.firstChild.data.tenantBoxVisible ?? true; - }; + get isTenantBoxVisibleForCurrentRoute() { + return this.getMostInnerChild().data.tenantBoxVisible ?? true; + } get isTenantBoxVisible() { - return this._tenantBoxVisible && this.multiTenancy.isTenantBoxVisible; + return this.isTenantBoxVisibleForCurrentRoute && this.multiTenancy.isTenantBoxVisible; } constructor( @@ -33,6 +31,16 @@ export class AuthWrapperService { injector: Injector, ) { this.route = injector.get(ActivatedRoute); - this.setTenantBoxVisibility(); + } + + private getMostInnerChild() { + let child = this.route.snapshot; + let depth = 0; + const depthLimit = 10; + while (child.firstChild && depth < depthLimit) { + child = child.firstChild; + depth++; + } + return child; } } From 7a33df11c21b354fe922e7ca78f638fed72d43ac Mon Sep 17 00:00:00 2001 From: bnymncoskuner Date: Tue, 13 Jul 2021 15:07:45 +0300 Subject: [PATCH 6/7] fix: add domainTenant back to MultiTenancyService --- .../core/src/lib/services/multi-tenancy.service.ts | 7 ++++++- .../core/src/lib/utils/multi-tenancy-utils.ts | 13 +++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts b/npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts index 7724106cfe..99371f91e7 100644 --- a/npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts @@ -2,7 +2,10 @@ import { Injectable, Inject } from '@angular/core'; import { switchMap, map } from 'rxjs/operators'; import { Observable } from 'rxjs'; import { ABP } from '../models/common'; -import { FindTenantResultDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models'; +import { + FindTenantResultDto, + CurrentTenantDto, +} from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models'; import { RestService } from './rest.service'; import { AbpTenantService } from '../proxy/pages/abp/multi-tenancy'; import { ConfigStateService } from './config-state.service'; @@ -11,6 +14,8 @@ import { TENANT_KEY } from '../tokens/tenant-key.token'; @Injectable({ providedIn: 'root' }) export class MultiTenancyService { + domainTenant: CurrentTenantDto = null; + isTenantBoxVisible = true; apiName = 'abp'; diff --git a/npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts index 87e4d68c9e..ea2b3d9765 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts @@ -35,15 +35,24 @@ export async function parseTenantFromUrl(injector: Injector) { multiTenancyService.isTenantBoxVisible = false; }; - const setEnvironmentWithTenant = (tenant: FindTenantResultDto) => { + const setDomainTenant = (tenant: FindTenantResultDto) => { + multiTenancyService.domainTenant = { + id: tenant.tenantId, + name: tenant.name, + isAvailable: true, + }; + }; + + const setEnvironmentWithDomainTenant = (tenant: FindTenantResultDto) => { hideTenantBox(); + setDomainTenant(tenant); replaceTenantNameWithinEnvironment(injector, tenant.name); }; if (tenancyName) { return multiTenancyService .setTenantByName(tenancyName) - .pipe(tap(setEnvironmentWithTenant)) + .pipe(tap(setEnvironmentWithDomainTenant)) .toPromise(); } else { /** From 92848ff399b1fcac9c32f3d5ae84228afa4b2016 Mon Sep 17 00:00:00 2001 From: bnymncoskuner Date: Tue, 13 Jul 2021 15:08:17 +0300 Subject: [PATCH 7/7] test: fix broken tests --- .../src/lib/tests/api.interceptor.spec.ts | 6 +++- .../lib/tests/config-state.service.spec.ts | 6 ++-- .../core/src/lib/tests/date-utils.spec.ts | 2 +- .../src/lib/tests/multi-tenancy-utils.spec.ts | 32 +++++++++++-------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/tests/api.interceptor.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/api.interceptor.spec.ts index ab289ddd9a..f731e4e7e5 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/api.interceptor.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/api.interceptor.spec.ts @@ -5,6 +5,7 @@ import { OAuthService } from 'angular-oauth2-oidc'; import { Subject, timer } from 'rxjs'; import { ApiInterceptor } from '../interceptors'; import { HttpWaitService, SessionStateService } from '../services'; +import { TENANT_KEY } from '../tokens/tenant-key.token'; describe('ApiInterceptor', () => { let spectator: SpectatorService; @@ -13,9 +14,12 @@ describe('ApiInterceptor', () => { let sessionState: SpyObject; let httpWaitService: SpyObject; + const testTenantKey = 'TEST_TENANT_KEY'; + const createService = createServiceFactory({ service: ApiInterceptor, mocks: [OAuthService, SessionStateService], + providers: [{ provide: TENANT_KEY, useValue: testTenantKey }], }); beforeEach(() => { @@ -38,7 +42,7 @@ describe('ApiInterceptor', () => { handle: (req: HttpRequest) => { expect(req.headers.get('Authorization')).toEqual('Bearer ey892mkwa8^2jk'); expect(req.headers.get('Accept-Language')).toEqual('tr'); - expect(req.headers.get('__tenant')).toEqual('Volosoft'); + expect(req.headers.get(testTenantKey)).toEqual('Volosoft'); done(); return handleRes$; }, diff --git a/npm/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts index 8f13beddf3..dad7a2c524 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts @@ -5,8 +5,9 @@ import { CurrentUserDto, } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models'; import { ConfigStateService } from '../services'; +import { CoreTestingModule } from '@abp/ng.core/testing'; -export const CONFIG_STATE_DATA = ({ +export const CONFIG_STATE_DATA = { environment: { production: false, application: { @@ -97,7 +98,7 @@ export const CONFIG_STATE_DATA = ({ }, }, registerLocaleFn: () => Promise.resolve(), -} as any) as ApplicationConfigurationDto; +} as any as ApplicationConfigurationDto; describe('ConfigState', () => { let spectator: SpectatorService; @@ -105,6 +106,7 @@ describe('ConfigState', () => { const createService = createServiceFactory({ service: ConfigStateService, + imports: [CoreTestingModule.withConfig()], }); beforeEach(() => { diff --git a/npm/ng-packs/packages/core/src/lib/tests/date-utils.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/date-utils.spec.ts index 764882847b..0bfebd2bcb 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/date-utils.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/date-utils.spec.ts @@ -15,7 +15,7 @@ describe('Date Utils', () => { let config: ConfigStateService; beforeEach(() => { - config = new ConfigStateService(); + config = new ConfigStateService(null); }); describe('#getShortDateFormat', () => { diff --git a/npm/ng-packs/packages/core/src/lib/tests/multi-tenancy-utils.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/multi-tenancy-utils.spec.ts index 66188f0bb3..5e49b64d22 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/multi-tenancy-utils.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/multi-tenancy-utils.spec.ts @@ -1,14 +1,15 @@ import { Component } from '@angular/core'; import { createComponentFactory, Spectator } from '@ngneat/spectator/jest'; import clone from 'just-clone'; -import { BehaviorSubject } from 'rxjs'; -import { AbpTenantService } from '../proxy/pages/abp/multi-tenancy/abp-tenant.service'; +import { of } from 'rxjs'; + import { CurrentTenantDto, FindTenantResultDto, } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models'; import { EnvironmentService, MultiTenancyService } from '../services'; import { parseTenantFromUrl } from '../utils'; +import { TENANT_KEY } from '../tokens'; const environment = { production: false, @@ -45,6 +46,8 @@ const setHref = url => { }); }; +const testTenantKey = 'TEST_TENANT_KEY'; + @Component({ selector: 'abp-dummy', template: '', @@ -56,7 +59,7 @@ describe('MultiTenancyUtils', () => { const createComponent = createComponentFactory({ component: DummyComponent, mocks: [EnvironmentService, MultiTenancyService], - providers: [{ provide: AbpTenantService, useValue: { findTenantByName: () => {} } }], + providers: [{ provide: TENANT_KEY, useValue: testTenantKey }], }); beforeEach(() => (spectator = createComponent())); @@ -65,27 +68,30 @@ describe('MultiTenancyUtils', () => { test('should get the tenancyName, set replaced environment and call the findTenantByName method of AbpTenantService', async () => { const environmentService = spectator.inject(EnvironmentService); const multiTenancyService = spectator.inject(MultiTenancyService); - const abpTenantService = spectator.inject(AbpTenantService); - const findTenantByNameSpy = jest.spyOn(abpTenantService, 'findTenantByName'); + const setTenantByName = jest.spyOn(multiTenancyService, 'setTenantByName'); const getEnvironmentSpy = jest.spyOn(environmentService, 'getEnvironment'); const setStateSpy = jest.spyOn(environmentService, 'setState'); getEnvironmentSpy.mockReturnValue(clone(environment)); + const testTenant: FindTenantResultDto = { + name: 'abp', + tenantId: '1', + isActive: true, + success: true, + }; + setHref('https://abp.volosoft.com/'); - findTenantByNameSpy.mockReturnValue( - new BehaviorSubject({ name: 'abp', tenantId: '1', success: true } as FindTenantResultDto), - ); + setTenantByName.mockReturnValue(of(testTenant)); const mockInjector = { get: arg => { if (arg === EnvironmentService) return environmentService; - if (arg === AbpTenantService) return abpTenantService; if (arg === MultiTenancyService) return multiTenancyService; }, }; - parseTenantFromUrl(mockInjector); + await parseTenantFromUrl(mockInjector); const replacedEnv = { ...environment, @@ -106,10 +112,10 @@ describe('MultiTenancyUtils', () => { }; expect(setStateSpy).toHaveBeenCalledWith(replacedEnv); - expect(findTenantByNameSpy).toHaveBeenCalledWith('abp', { __tenant: '' }); expect(multiTenancyService.domainTenant).toEqual({ - id: '1', - name: 'abp', + id: testTenant.tenantId, + name: testTenant.name, + isAvailable: true, } as CurrentTenantDto); }); });