diff --git a/src/Logitar.Identity.Domain/Logitar.Identity.Domain.csproj b/src/Logitar.Identity.Domain/Logitar.Identity.Domain.csproj index a8d264f..275dbcf 100644 --- a/src/Logitar.Identity.Domain/Logitar.Identity.Domain.csproj +++ b/src/Logitar.Identity.Domain/Logitar.Identity.Domain.csproj @@ -45,13 +45,13 @@ - + - + diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/DependencyInjectionExtensions.cs b/src/Logitar.Identity.EntityFrameworkCore.Relational/DependencyInjectionExtensions.cs index 763a4bd..abcabc7 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/DependencyInjectionExtensions.cs +++ b/src/Logitar.Identity.EntityFrameworkCore.Relational/DependencyInjectionExtensions.cs @@ -1,5 +1,4 @@ using Logitar.EventSourcing.EntityFrameworkCore.Relational; -using Logitar.EventSourcing.Infrastructure; using Logitar.Identity.Domain.ApiKeys; using Logitar.Identity.Domain.Passwords; using Logitar.Identity.Domain.Roles; @@ -7,14 +6,11 @@ using Logitar.Identity.Domain.Tokens; using Logitar.Identity.Domain.Users; using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.ApiKeys; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Passwords; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Roles; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Sessions; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Users; +using Logitar.Identity.EntityFrameworkCore.Relational.Handlers; using Logitar.Identity.EntityFrameworkCore.Relational.Repositories; using Logitar.Identity.EntityFrameworkCore.Relational.Tokens; using Logitar.Identity.Infrastructure; +using Logitar.Identity.Infrastructure.Handlers; using Microsoft.Extensions.DependencyInjection; namespace Logitar.Identity.EntityFrameworkCore.Relational; @@ -30,7 +26,6 @@ public static IServiceCollection AddLogitarIdentityWithEntityFrameworkCoreRelati .AddMediatR(config => config.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly())) .AddRepositories() .AddTransient() - .AddTransient() .AddTransient(); } diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeys/ApiKeyEventHandler.cs b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeyEventHandler.cs similarity index 98% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeys/ApiKeyEventHandler.cs rename to src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeyEventHandler.cs index a9f5af5..8c586a2 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeys/ApiKeyEventHandler.cs +++ b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeyEventHandler.cs @@ -2,9 +2,10 @@ using Logitar.Identity.Domain.ApiKeys.Events; using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes; using Logitar.Identity.EntityFrameworkCore.Relational.Entities; +using Logitar.Identity.Infrastructure.Handlers; using Microsoft.EntityFrameworkCore; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.ApiKeys; +namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers; public class ApiKeyEventHandler : IApiKeyEventHandler { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Passwords/OneTimePasswordEventHandler.cs b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/OneTimePasswordEventHandler.cs similarity index 98% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Passwords/OneTimePasswordEventHandler.cs rename to src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/OneTimePasswordEventHandler.cs index a5ec580..96f86c4 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Passwords/OneTimePasswordEventHandler.cs +++ b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/OneTimePasswordEventHandler.cs @@ -2,9 +2,10 @@ using Logitar.Identity.Domain.Passwords.Events; using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes; using Logitar.Identity.EntityFrameworkCore.Relational.Entities; +using Logitar.Identity.Infrastructure.Handlers; using Microsoft.EntityFrameworkCore; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Passwords; +namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers; public class OneTimePasswordEventHandler : IOneTimePasswordEventHandler { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Roles/RoleEventHandler.cs b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/RoleEventHandler.cs similarity index 98% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Roles/RoleEventHandler.cs rename to src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/RoleEventHandler.cs index 69a886a..2c25832 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Roles/RoleEventHandler.cs +++ b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/RoleEventHandler.cs @@ -2,9 +2,10 @@ using Logitar.Identity.Domain.Roles.Events; using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes; using Logitar.Identity.EntityFrameworkCore.Relational.Entities; +using Logitar.Identity.Infrastructure.Handlers; using Microsoft.EntityFrameworkCore; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Roles; +namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers; public class RoleEventHandler : IRoleEventHandler { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Sessions/SessionEventHandler.cs b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/SessionEventHandler.cs similarity index 98% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Sessions/SessionEventHandler.cs rename to src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/SessionEventHandler.cs index 4c831b5..dcd61b2 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Sessions/SessionEventHandler.cs +++ b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/SessionEventHandler.cs @@ -2,9 +2,10 @@ using Logitar.Identity.Domain.Sessions.Events; using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes; using Logitar.Identity.EntityFrameworkCore.Relational.Entities; +using Logitar.Identity.Infrastructure.Handlers; using Microsoft.EntityFrameworkCore; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Sessions; +namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers; public class SessionEventHandler : ISessionEventHandler { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Users/UserEventHandler.cs b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/UserEventHandler.cs similarity index 96% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Users/UserEventHandler.cs rename to src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/UserEventHandler.cs index e89082d..1cec73e 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Users/UserEventHandler.cs +++ b/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/UserEventHandler.cs @@ -2,9 +2,10 @@ using Logitar.Identity.Domain.Users.Events; using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes; using Logitar.Identity.EntityFrameworkCore.Relational.Entities; +using Logitar.Identity.Infrastructure.Handlers; using Microsoft.EntityFrameworkCore; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Users; +namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers; public class UserEventHandler : IUserEventHandler { @@ -152,8 +153,8 @@ public virtual async Task HandleAsync(UserRoleAddedEvent @event, CancellationTok if (user != null) { RoleEntity role = await Context.Roles - .SingleOrDefaultAsync(x => x.AggregateId == @event.RoleId.AggregateId.Value, cancellationToken) - ?? throw new InvalidOperationException($"The role entity 'AggregateId={@event.AggregateId}' could not be found."); + .SingleOrDefaultAsync(x => x.AggregateId == @event.RoleId.AggregateId.Value, cancellationToken) + ?? throw new InvalidOperationException($"The role entity 'AggregateId={@event.AggregateId}' could not be found."); user.AddRole(role, @event); diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Logitar.Identity.EntityFrameworkCore.Relational.csproj b/src/Logitar.Identity.EntityFrameworkCore.Relational/Logitar.Identity.EntityFrameworkCore.Relational.csproj index da18498..192138a 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Logitar.Identity.EntityFrameworkCore.Relational.csproj +++ b/src/Logitar.Identity.EntityFrameworkCore.Relational/Logitar.Identity.EntityFrameworkCore.Relational.csproj @@ -46,7 +46,6 @@ - diff --git a/src/Logitar.Identity.Infrastructure/DependencyInjectionExtensions.cs b/src/Logitar.Identity.Infrastructure/DependencyInjectionExtensions.cs index ffd022e..d1ca96a 100644 --- a/src/Logitar.Identity.Infrastructure/DependencyInjectionExtensions.cs +++ b/src/Logitar.Identity.Infrastructure/DependencyInjectionExtensions.cs @@ -27,11 +27,12 @@ public static IServiceCollection AddLogitarIdentityInfrastructure(this IServiceC IConfiguration configuration = serviceProvider.GetRequiredService(); return configuration.GetSection("Pbkdf2").Get() ?? new(); }) + .AddTransient() .AddTransient(); } - public static IEnumerable GetLogitarIdentityJsonConverters(this IServiceProvider serviceProvider) => new JsonConverter[] - { + public static IEnumerable GetLogitarIdentityJsonConverters(this IServiceProvider serviceProvider) => + [ serviceProvider.GetRequiredService(), new ApiKeyIdConverter(), new DescriptionConverter(), @@ -47,7 +48,7 @@ public static IServiceCollection AddLogitarIdentityInfrastructure(this IServiceC new UniqueNameConverter(), new UrlConverter(), new UserIdConverter() - }; + ]; private static IServiceCollection AddPasswordStrategies(this IServiceCollection services) { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/EventBus.cs b/src/Logitar.Identity.Infrastructure/EventBus.cs similarity index 94% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/EventBus.cs rename to src/Logitar.Identity.Infrastructure/EventBus.cs index b4746f9..5aef56a 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/EventBus.cs +++ b/src/Logitar.Identity.Infrastructure/EventBus.cs @@ -5,14 +5,10 @@ using Logitar.Identity.Domain.Roles.Events; using Logitar.Identity.Domain.Sessions.Events; using Logitar.Identity.Domain.Users.Events; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.ApiKeys; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Passwords; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Roles; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Sessions; -using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Users; +using Logitar.Identity.Infrastructure.Handlers; using MediatR; -namespace Logitar.Identity.EntityFrameworkCore.Relational; +namespace Logitar.Identity.Infrastructure; public class EventBus : IEventBus { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeys/IApiKeyEventHandler.cs b/src/Logitar.Identity.Infrastructure/Handlers/IApiKeyEventHandler.cs similarity index 89% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeys/IApiKeyEventHandler.cs rename to src/Logitar.Identity.Infrastructure/Handlers/IApiKeyEventHandler.cs index c8da165..8f1b620 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/ApiKeys/IApiKeyEventHandler.cs +++ b/src/Logitar.Identity.Infrastructure/Handlers/IApiKeyEventHandler.cs @@ -1,6 +1,6 @@ using Logitar.Identity.Domain.ApiKeys.Events; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.ApiKeys; +namespace Logitar.Identity.Infrastructure.Handlers; public interface IApiKeyEventHandler { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Passwords/IOneTimePasswordEventHandler.cs b/src/Logitar.Identity.Infrastructure/Handlers/IOneTimePasswordEventHandler.cs similarity index 89% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Passwords/IOneTimePasswordEventHandler.cs rename to src/Logitar.Identity.Infrastructure/Handlers/IOneTimePasswordEventHandler.cs index c1ea343..aac71e6 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Passwords/IOneTimePasswordEventHandler.cs +++ b/src/Logitar.Identity.Infrastructure/Handlers/IOneTimePasswordEventHandler.cs @@ -1,6 +1,6 @@ using Logitar.Identity.Domain.Passwords.Events; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Passwords; +namespace Logitar.Identity.Infrastructure.Handlers; public interface IOneTimePasswordEventHandler { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Roles/IRoleEventHandler.cs b/src/Logitar.Identity.Infrastructure/Handlers/IRoleEventHandler.cs similarity index 86% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Roles/IRoleEventHandler.cs rename to src/Logitar.Identity.Infrastructure/Handlers/IRoleEventHandler.cs index 167bfdf..dec3deb 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Roles/IRoleEventHandler.cs +++ b/src/Logitar.Identity.Infrastructure/Handlers/IRoleEventHandler.cs @@ -1,6 +1,6 @@ using Logitar.Identity.Domain.Roles.Events; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Roles; +namespace Logitar.Identity.Infrastructure.Handlers; public interface IRoleEventHandler { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Sessions/ISessionEventHandler.cs b/src/Logitar.Identity.Infrastructure/Handlers/ISessionEventHandler.cs similarity index 88% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Sessions/ISessionEventHandler.cs rename to src/Logitar.Identity.Infrastructure/Handlers/ISessionEventHandler.cs index 63a1f8b..37c7aca 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Sessions/ISessionEventHandler.cs +++ b/src/Logitar.Identity.Infrastructure/Handlers/ISessionEventHandler.cs @@ -1,6 +1,6 @@ using Logitar.Identity.Domain.Sessions.Events; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Sessions; +namespace Logitar.Identity.Infrastructure.Handlers; public interface ISessionEventHandler { diff --git a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Users/IUserEventHandler.cs b/src/Logitar.Identity.Infrastructure/Handlers/IUserEventHandler.cs similarity index 95% rename from src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Users/IUserEventHandler.cs rename to src/Logitar.Identity.Infrastructure/Handlers/IUserEventHandler.cs index 5a27a38..5ecb713 100644 --- a/src/Logitar.Identity.EntityFrameworkCore.Relational/Handlers/Users/IUserEventHandler.cs +++ b/src/Logitar.Identity.Infrastructure/Handlers/IUserEventHandler.cs @@ -1,6 +1,6 @@ using Logitar.Identity.Domain.Users.Events; -namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Users; +namespace Logitar.Identity.Infrastructure.Handlers; public interface IUserEventHandler { diff --git a/src/Logitar.Identity.Infrastructure/Logitar.Identity.Infrastructure.csproj b/src/Logitar.Identity.Infrastructure/Logitar.Identity.Infrastructure.csproj index 52d7155..91b3c98 100644 --- a/src/Logitar.Identity.Infrastructure/Logitar.Identity.Infrastructure.csproj +++ b/src/Logitar.Identity.Infrastructure/Logitar.Identity.Infrastructure.csproj @@ -45,8 +45,9 @@ - - + + +