Merge pull request #3210 from abpframework/Cotur-Eto-Identity

Identity ETO's added
pull/3240/head
Halil İbrahim Kalkan 5 years ago committed by GitHub
commit e3e8e9a9fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,24 @@
using System;
namespace Volo.Abp.Identity
{
[Serializable]
public class IdentityClaimTypeEto
{
public Guid Id { get; set; }
public string Name { get; set; }
public bool Required { get; set; }
public bool IsStatic { get; set; }
public string Regex { get; set; }
public string RegexDescription { get; set; }
public string Description { get; set; }
public IdentityClaimValueType ValueType { get; set; }
}
}

@ -0,0 +1,20 @@
using System;
namespace Volo.Abp.Identity
{
[Serializable]
public class IdentityRoleEto
{
public Guid Id { get; set; }
public Guid? TenantId { get; set; }
public string Name { get; set; }
public bool IsDefault { get; set; }
public bool IsStatic { get; set; }
public bool IsPublic { get; set; }
}
}

@ -25,6 +25,7 @@
<ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.Domain\Volo.Abp.Users.Domain.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Ddd.Domain\Volo.Abp.Ddd.Domain.csproj" />
</ItemGroup>

@ -2,6 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Volo.Abp.AutoMapper;
using Volo.Abp.Domain;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Modularity;
@ -12,17 +13,27 @@ namespace Volo.Abp.Identity
[DependsOn(
typeof(AbpDddDomainModule),
typeof(AbpIdentityDomainSharedModule),
typeof(AbpUsersDomainModule)
typeof(AbpUsersDomainModule),
typeof(AbpAutoMapperModule)
)]
public class AbpIdentityDomainModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpDistributedEventBusOptions>(options =>
context.Services.AddAutoMapperObjectMapper<AbpIdentityDomainModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.EtoMappings.Add<IdentityUser, UserEto>();
options.AddProfile<IdentityDomainMappingProfile>(validate: true);
});
Configure<AbpDistributedEventBusOptions>(options =>
{
options.EtoMappings.Add<IdentityUser, UserEto>(typeof(AbpIdentityDomainModule));
options.EtoMappings.Add<IdentityClaimType, IdentityClaimTypeEto>(typeof(AbpIdentityDomainModule));
options.EtoMappings.Add<IdentityRole, IdentityRoleEto>(typeof(AbpIdentityDomainModule));
});
var identityBuilder = context.Services.AddAbpIdentity(options =>
{
options.User.RequireUniqueEmail = true;

@ -0,0 +1,15 @@
using AutoMapper;
using Volo.Abp.Users;
namespace Volo.Abp.Identity
{
public class IdentityDomainMappingProfile : Profile
{
public IdentityDomainMappingProfile()
{
CreateMap<IdentityUser, UserEto>();
CreateMap<IdentityClaimType, IdentityClaimTypeEto>();
CreateMap<IdentityRole, IdentityRoleEto>();
}
}
}

@ -8,12 +8,11 @@ using Microsoft.AspNetCore.Identity;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Users;
namespace Volo.Abp.Identity
{
public class IdentityUser : FullAuditedAggregateRoot<Guid>, IUser, IMapTo<UserEto>
public class IdentityUser : FullAuditedAggregateRoot<Guid>, IUser
{
public virtual Guid? TenantId { get; protected set; }
@ -281,36 +280,5 @@ namespace Volo.Abp.Identity
{
return $"{base.ToString()}, UserName = {UserName}";
}
UserEto IMapTo<UserEto>.MapTo()
{
//TODO: Instead, consider to use automapper (but it makes dependency just for a small code part)??
return new UserEto
{
Name = Name,
Email = Email,
EmailConfirmed = EmailConfirmed,
Id = Id,
PhoneNumber = PhoneNumber,
PhoneNumberConfirmed = PhoneNumberConfirmed,
Surname = Surname,
TenantId = TenantId,
UserName = UserName
};
}
void IMapTo<UserEto>.MapTo(UserEto destination)
{
destination.Name = Name;
destination.Email = Email;
destination.EmailConfirmed = EmailConfirmed;
destination.Id = Id;
destination.PhoneNumber = PhoneNumber;
destination.PhoneNumberConfirmed = PhoneNumberConfirmed;
destination.Surname = Surname;
destination.TenantId = TenantId;
destination.UserName = UserName;
}
}
}

Loading…
Cancel
Save