Browse Source
Merge pull request #8814 from abpframework/maliming/Tenant-Active-Passive
Add IsActive property to TenantConfiguration.
pull/8884/head
Halil İbrahim Kalkan
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
27 additions and
10 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantAppService.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs
-
framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfiguration.cs
-
framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConfigurationProvider.cs
-
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMappingProfile.cs
|
|
|
@ -10,5 +10,7 @@ namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy |
|
|
|
public Guid? TenantId { get; set; } |
|
|
|
|
|
|
|
public string Name { get; set; } |
|
|
|
|
|
|
|
public bool IsActive { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -28,10 +28,11 @@ namespace Pages.Abp.MultiTenancy |
|
|
|
{ |
|
|
|
Success = true, |
|
|
|
TenantId = tenant.Id, |
|
|
|
Name = tenant.Name |
|
|
|
Name = tenant.Name, |
|
|
|
IsActive = tenant.IsActive |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<FindTenantResultDto> FindTenantByIdAsync(Guid id) |
|
|
|
{ |
|
|
|
var tenant = await TenantStore.FindAsync(id); |
|
|
|
@ -45,8 +46,9 @@ namespace Pages.Abp.MultiTenancy |
|
|
|
{ |
|
|
|
Success = true, |
|
|
|
TenantId = tenant.Id, |
|
|
|
Name = tenant.Name |
|
|
|
Name = tenant.Name, |
|
|
|
IsActive = tenant.IsActive |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -20,7 +20,7 @@ namespace Pages.Abp.MultiTenancy |
|
|
|
protected AbpAspNetCoreMultiTenancyOptions Options { get; } |
|
|
|
|
|
|
|
public TenantSwitchModalModel( |
|
|
|
ITenantStore tenantStore, |
|
|
|
ITenantStore tenantStore, |
|
|
|
IOptions<AbpAspNetCoreMultiTenancyOptions> options) |
|
|
|
{ |
|
|
|
TenantStore = tenantStore; |
|
|
|
@ -48,7 +48,7 @@ namespace Pages.Abp.MultiTenancy |
|
|
|
else |
|
|
|
{ |
|
|
|
var tenant = await TenantStore.FindAsync(Input.Name); |
|
|
|
if (tenant == null) |
|
|
|
if (tenant == null || !tenant.IsActive) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException(L["GivenTenantIsNotAvailable", Input.Name]); |
|
|
|
} |
|
|
|
@ -71,4 +71,4 @@ namespace Pages.Abp.MultiTenancy |
|
|
|
public string Name { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -13,12 +13,15 @@ namespace Volo.Abp.MultiTenancy |
|
|
|
|
|
|
|
public ConnectionStrings ConnectionStrings { get; set; } |
|
|
|
|
|
|
|
public bool IsActive { get; set; } |
|
|
|
|
|
|
|
public TenantConfiguration() |
|
|
|
{ |
|
|
|
|
|
|
|
IsActive = true; |
|
|
|
} |
|
|
|
|
|
|
|
public TenantConfiguration(Guid id, [NotNull] string name) |
|
|
|
: this() |
|
|
|
{ |
|
|
|
Check.NotNull(name, nameof(name)); |
|
|
|
|
|
|
|
|
|
|
|
@ -42,6 +42,15 @@ namespace Volo.Abp.MultiTenancy |
|
|
|
details: "There is no tenant with the tenant id or name: " + resolveResult.TenantIdOrName |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
if (!tenant.IsActive) |
|
|
|
{ |
|
|
|
throw new BusinessException( |
|
|
|
code: "Volo.AbpIo.MultiTenancy:010002", |
|
|
|
message: "Tenant not active!", |
|
|
|
details: "The tenant is no active with the tenant id or name: " + resolveResult.TenantIdOrName |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return tenant; |
|
|
|
|
|
|
|
@ -22,7 +22,8 @@ namespace Volo.Abp.TenantManagement |
|
|
|
|
|
|
|
return connStrings; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}) |
|
|
|
.ForMember(x => x.IsActive, x => x.Ignore()); |
|
|
|
|
|
|
|
CreateMap<Tenant, TenantEto>(); |
|
|
|
} |
|
|
|
|