Browse Source
Merge pull request #3107 from abpframework/Cotur-TenantManagement
Custom admin/pass implementation for new tenant
pull/3146/head
Halil İbrahim Kalkan
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with
45 additions and
10 deletions
-
modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantCreateDto.cs
-
modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantCreateOrUpdateDtoBase.cs
-
modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/TenantAppService.cs
-
modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi/Volo/Abp/TenantManagement/TenantController.cs
-
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Pages/TenantManagement/Tenants/CreateModal.cshtml
-
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Pages/TenantManagement/Tenants/CreateModal.cshtml.cs
-
modules/tenant-management/test/Volo.Abp.TenantManagement.Application.Tests/Volo/Abp/TenantManagement/TenantAppService_Tests.cs
|
|
|
@ -1,7 +1,22 @@ |
|
|
|
namespace Volo.Abp.TenantManagement |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Localization; |
|
|
|
using Volo.Abp.TenantManagement.Localization; |
|
|
|
|
|
|
|
namespace Volo.Abp.TenantManagement |
|
|
|
{ |
|
|
|
public class TenantCreateDto : TenantCreateOrUpdateDtoBase |
|
|
|
{ |
|
|
|
[Required] |
|
|
|
[EmailAddress] |
|
|
|
[MaxLength(256)] |
|
|
|
public string AdminEmailAddress { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
[Required] |
|
|
|
[MaxLength(128)] |
|
|
|
public string AdminPassword { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1,7 +1,11 @@ |
|
|
|
namespace Volo.Abp.TenantManagement |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
|
|
|
|
namespace Volo.Abp.TenantManagement |
|
|
|
{ |
|
|
|
public abstract class TenantCreateOrUpdateDtoBase |
|
|
|
{ |
|
|
|
[Required] |
|
|
|
[StringLength(TenantConsts.MaxNameLength)] |
|
|
|
public string Name { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
@ -15,7 +15,7 @@ namespace Volo.Abp.TenantManagement |
|
|
|
protected ITenantManager TenantManager { get; } |
|
|
|
|
|
|
|
public TenantAppService( |
|
|
|
ITenantRepository tenantRepository, |
|
|
|
ITenantRepository tenantRepository, |
|
|
|
ITenantManager tenantManager, |
|
|
|
IDataSeeder dataSeeder) |
|
|
|
{ |
|
|
|
@ -51,10 +51,13 @@ namespace Volo.Abp.TenantManagement |
|
|
|
{ |
|
|
|
//TODO: Handle database creation?
|
|
|
|
|
|
|
|
//TODO: Set admin email & password..?
|
|
|
|
await DataSeeder.SeedAsync(tenant.Id); |
|
|
|
await DataSeeder.SeedAsync( |
|
|
|
new DataSeedContext(tenant.Id) |
|
|
|
.WithProperty("AdminEmail", input.AdminEmailAddress) |
|
|
|
.WithProperty("AdminPassword", input.AdminPassword) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ObjectMapper.Map<Tenant, TenantDto>(tenant); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -35,6 +35,7 @@ namespace Volo.Abp.TenantManagement |
|
|
|
[HttpPost] |
|
|
|
public virtual Task<TenantDto> CreateAsync(TenantCreateDto input) |
|
|
|
{ |
|
|
|
ValidateModel(); |
|
|
|
return _service.CreateAsync(input); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -12,7 +12,11 @@ |
|
|
|
<abp-modal> |
|
|
|
<abp-modal-header title="@L["NewTenant"]"></abp-modal-header> |
|
|
|
<abp-modal-body> |
|
|
|
<abp-input asp-for="Tenant.Name" label="@L["TenantName"].Value" /> |
|
|
|
<abp-input asp-for="Tenant.Name" /> |
|
|
|
|
|
|
|
<abp-input asp-for="Tenant.AdminEmailAddress" /> |
|
|
|
|
|
|
|
<abp-input asp-for="Tenant.AdminPassword" /> |
|
|
|
</abp-modal-body> |
|
|
|
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
|
|
|
</abp-modal> |
|
|
|
|
|
|
|
@ -31,8 +31,16 @@ namespace Volo.Abp.TenantManagement.Web.Pages.TenantManagement.Tenants |
|
|
|
{ |
|
|
|
[Required] |
|
|
|
[StringLength(TenantConsts.MaxNameLength)] |
|
|
|
[Display(Name = "DisplayName:TenantName")] |
|
|
|
public string Name { get; set; } |
|
|
|
|
|
|
|
[Required] |
|
|
|
[EmailAddress] |
|
|
|
[MaxLength(256)] |
|
|
|
public string AdminEmailAddress { get; set; } |
|
|
|
|
|
|
|
[Required] |
|
|
|
[MaxLength(128)] |
|
|
|
public string AdminPassword { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -59,7 +59,7 @@ namespace Volo.Abp.TenantManagement |
|
|
|
public async Task CreateAsync() |
|
|
|
{ |
|
|
|
var tenancyName = Guid.NewGuid().ToString("N").ToLowerInvariant(); |
|
|
|
var tenant = await _tenantAppService.CreateAsync(new TenantCreateDto { Name = tenancyName }); |
|
|
|
var tenant = await _tenantAppService.CreateAsync(new TenantCreateDto { Name = tenancyName , AdminEmailAddress = "admin@admin.com", AdminPassword = "123456"}); |
|
|
|
tenant.Name.ShouldBe(tenancyName); |
|
|
|
tenant.Id.ShouldNotBe(default(Guid)); |
|
|
|
} |
|
|
|
@ -69,7 +69,7 @@ namespace Volo.Abp.TenantManagement |
|
|
|
{ |
|
|
|
await Assert.ThrowsAsync<UserFriendlyException>(async () => |
|
|
|
{ |
|
|
|
await _tenantAppService.CreateAsync(new TenantCreateDto { Name = "acme" }); |
|
|
|
await _tenantAppService.CreateAsync(new TenantCreateDto { Name = "acme", AdminEmailAddress = "admin@admin.com", AdminPassword = "123456" }); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|