diff --git a/TravelGuide.sln b/TravelGuide.sln
index f012d1c..75d3e9c 100644
--- a/TravelGuide.sln
+++ b/TravelGuide.sln
@@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "src\Infra
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpApi", "src\HttpApi\HttpApi.csproj", "{4431B3CB-A5F2-447A-8BC7-9DC3DA9E6A6D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identity", "src\Identity\Identity.csproj", "{AD3CC01F-0331-44DC-B58E-CCE6ADCB56B6}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Configuration", "src\Configuration\Configuration.csproj", "{1DCFA4EE-A545-42FE-A3BC-A606D2961298}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application.IntegrationTests", "tst\Application.IntegrationTests\Application.IntegrationTests.csproj", "{B52B8651-10B8-488D-8ACF-9C4499F8A723}"
@@ -48,10 +46,6 @@ Global
{4431B3CB-A5F2-447A-8BC7-9DC3DA9E6A6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4431B3CB-A5F2-447A-8BC7-9DC3DA9E6A6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4431B3CB-A5F2-447A-8BC7-9DC3DA9E6A6D}.Release|Any CPU.Build.0 = Release|Any CPU
- {AD3CC01F-0331-44DC-B58E-CCE6ADCB56B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {AD3CC01F-0331-44DC-B58E-CCE6ADCB56B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {AD3CC01F-0331-44DC-B58E-CCE6ADCB56B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {AD3CC01F-0331-44DC-B58E-CCE6ADCB56B6}.Release|Any CPU.Build.0 = Release|Any CPU
{1DCFA4EE-A545-42FE-A3BC-A606D2961298}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DCFA4EE-A545-42FE-A3BC-A606D2961298}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DCFA4EE-A545-42FE-A3BC-A606D2961298}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/src/Application/Addresses/Commands/AddAddress/AddAddressCommandAuthorizer.cs b/src/Application/Addresses/Commands/AddAddress/AddAddressCommandAuthorizer.cs
index eb8ae61..6c88c27 100644
--- a/src/Application/Addresses/Commands/AddAddress/AddAddressCommandAuthorizer.cs
+++ b/src/Application/Addresses/Commands/AddAddress/AddAddressCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Addresses.Commands.AddAddress;
diff --git a/src/Application/Addresses/Commands/AddAddress/AddAddressCommandHandler.cs b/src/Application/Addresses/Commands/AddAddress/AddAddressCommandHandler.cs
index 5aaf4f9..189c8d0 100644
--- a/src/Application/Addresses/Commands/AddAddress/AddAddressCommandHandler.cs
+++ b/src/Application/Addresses/Commands/AddAddress/AddAddressCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Addresses/Commands/AddAddress/AddAddressCommandValidator.cs b/src/Application/Addresses/Commands/AddAddress/AddAddressCommandValidator.cs
index 59adff1..e1c38c8 100644
--- a/src/Application/Addresses/Commands/AddAddress/AddAddressCommandValidator.cs
+++ b/src/Application/Addresses/Commands/AddAddress/AddAddressCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Addresses/Commands/DeleteAddress/DeleteAddressCommandAuthorizer.cs b/src/Application/Addresses/Commands/DeleteAddress/DeleteAddressCommandAuthorizer.cs
index e8e04ca..7b5bb31 100644
--- a/src/Application/Addresses/Commands/DeleteAddress/DeleteAddressCommandAuthorizer.cs
+++ b/src/Application/Addresses/Commands/DeleteAddress/DeleteAddressCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Addresses.Commands.DeleteAddress;
diff --git a/src/Application/Addresses/Commands/DeleteAddress/DeleteAddressCommandHandler.cs b/src/Application/Addresses/Commands/DeleteAddress/DeleteAddressCommandHandler.cs
index 428b7fa..fc6ea4c 100644
--- a/src/Application/Addresses/Commands/DeleteAddress/DeleteAddressCommandHandler.cs
+++ b/src/Application/Addresses/Commands/DeleteAddress/DeleteAddressCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Addresses.Commands.DeleteAddress;
diff --git a/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandAuthorizer.cs b/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandAuthorizer.cs
index 1063a38..80860d1 100644
--- a/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandAuthorizer.cs
+++ b/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Addresses.Commands.UpdateAddress;
diff --git a/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandHandler.cs b/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandHandler.cs
index eba7089..17ab45f 100644
--- a/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandHandler.cs
+++ b/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandValidator.cs b/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandValidator.cs
index ceae48d..adf0322 100644
--- a/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandValidator.cs
+++ b/src/Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Addresses/Queries/GetAddress/GetAddressQueryAuthorizer.cs b/src/Application/Addresses/Queries/GetAddress/GetAddressQueryAuthorizer.cs
index 545dd25..d6cfa6c 100644
--- a/src/Application/Addresses/Queries/GetAddress/GetAddressQueryAuthorizer.cs
+++ b/src/Application/Addresses/Queries/GetAddress/GetAddressQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Addresses.Queries.GetAddress;
diff --git a/src/Application/Addresses/Queries/GetAddress/GetAddressQueryHandler.cs b/src/Application/Addresses/Queries/GetAddress/GetAddressQueryHandler.cs
index f0f5a86..730b248 100644
--- a/src/Application/Addresses/Queries/GetAddress/GetAddressQueryHandler.cs
+++ b/src/Application/Addresses/Queries/GetAddress/GetAddressQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryAuthorizer.cs b/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryAuthorizer.cs
index b8d21da..6521dde 100644
--- a/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryAuthorizer.cs
+++ b/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Addresses.Queries.GetAddressesPage;
diff --git a/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryHandler.cs b/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryHandler.cs
index 9b4cd25..4fcce04 100644
--- a/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryHandler.cs
+++ b/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryValidator.cs b/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryValidator.cs
index b1eb480..ce7adfe 100644
--- a/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryValidator.cs
+++ b/src/Application/Addresses/Queries/GetAddressesPage/GetAddressesPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandAuthorizer.cs b/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandAuthorizer.cs
index 8c98851..46621fb 100644
--- a/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandAuthorizer.cs
+++ b/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Aircrafts.Commands.AddAircraft;
diff --git a/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandHandler.cs b/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandHandler.cs
index a210946..fdb46dd 100644
--- a/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandHandler.cs
+++ b/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandValidator.cs b/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandValidator.cs
index b37dbac..15253f2 100644
--- a/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandValidator.cs
+++ b/src/Application/Aircrafts/Commands/AddAircraft/AddAircraftCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Aircrafts/Commands/DeleteAircraft/DeleteAircraftCommandAuthorizer.cs b/src/Application/Aircrafts/Commands/DeleteAircraft/DeleteAircraftCommandAuthorizer.cs
index 97f1463..1aeae2a 100644
--- a/src/Application/Aircrafts/Commands/DeleteAircraft/DeleteAircraftCommandAuthorizer.cs
+++ b/src/Application/Aircrafts/Commands/DeleteAircraft/DeleteAircraftCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Aircrafts.Commands.DeleteAircraft;
diff --git a/src/Application/Aircrafts/Commands/DeleteAircraft/DeleteAircraftCommandHandler.cs b/src/Application/Aircrafts/Commands/DeleteAircraft/DeleteAircraftCommandHandler.cs
index 2188c03..1d3d867 100644
--- a/src/Application/Aircrafts/Commands/DeleteAircraft/DeleteAircraftCommandHandler.cs
+++ b/src/Application/Aircrafts/Commands/DeleteAircraft/DeleteAircraftCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Aircrafts.Commands.DeleteAircraft;
diff --git a/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandAuthorizer.cs b/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandAuthorizer.cs
index c7036f5..b15c281 100644
--- a/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandAuthorizer.cs
+++ b/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Aircrafts.Commands.UpdateAircraft;
diff --git a/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandHandler.cs b/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandHandler.cs
index d046aa9..9d16e38 100644
--- a/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandHandler.cs
+++ b/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandValidator.cs b/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandValidator.cs
index fb9dbc8..8060418 100644
--- a/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandValidator.cs
+++ b/src/Application/Aircrafts/Commands/UpdateAircraft/UpdateAircraftCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Aircrafts/Queries/GetAircraft/GetAircraftQueryAuthorizer.cs b/src/Application/Aircrafts/Queries/GetAircraft/GetAircraftQueryAuthorizer.cs
index 121cf58..a0cc4e2 100644
--- a/src/Application/Aircrafts/Queries/GetAircraft/GetAircraftQueryAuthorizer.cs
+++ b/src/Application/Aircrafts/Queries/GetAircraft/GetAircraftQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Aircrafts.Queries.GetAircraft;
diff --git a/src/Application/Aircrafts/Queries/GetAircraft/GetAircraftQueryHandler.cs b/src/Application/Aircrafts/Queries/GetAircraft/GetAircraftQueryHandler.cs
index 01e7454..2977272 100644
--- a/src/Application/Aircrafts/Queries/GetAircraft/GetAircraftQueryHandler.cs
+++ b/src/Application/Aircrafts/Queries/GetAircraft/GetAircraftQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryAuthorizer.cs b/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryAuthorizer.cs
index 79a0546..41b94bb 100644
--- a/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryAuthorizer.cs
+++ b/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Aircrafts.Queries.GetAircraftsPage;
diff --git a/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryHandler.cs b/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryHandler.cs
index e4a59c3..586d197 100644
--- a/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryHandler.cs
+++ b/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryValidator.cs b/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryValidator.cs
index 49c58b3..c564c40 100644
--- a/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryValidator.cs
+++ b/src/Application/Aircrafts/Queries/GetAircraftsPage/GetAircraftsPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Application.csproj b/src/Application/Application.csproj
index 0e77ba6..e6484da 100644
--- a/src/Application/Application.csproj
+++ b/src/Application/Application.csproj
@@ -16,7 +16,10 @@
+
+
+
diff --git a/src/Application/Authentication/Commands/Register/RegisterCommand.cs b/src/Application/Authentication/Commands/Register/RegisterCommand.cs
index 51edec4..41a1dbc 100644
--- a/src/Application/Authentication/Commands/Register/RegisterCommand.cs
+++ b/src/Application/Authentication/Commands/Register/RegisterCommand.cs
@@ -4,6 +4,8 @@ namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.Register;
public record RegisterCommand : IRequest
{
+ public string Username { get; set; }
+
public string Email { get; set; }
public string Password { get; set; }
diff --git a/src/Application/Authentication/Commands/Register/RegisterCommandAuthorizer.cs b/src/Application/Authentication/Commands/Register/RegisterCommandAuthorizer.cs
new file mode 100644
index 0000000..d3fc40f
--- /dev/null
+++ b/src/Application/Authentication/Commands/Register/RegisterCommandAuthorizer.cs
@@ -0,0 +1,13 @@
+using cuqmbr.TravelGuide.Application.Common.Authorization;
+using MediatR.Behaviors.Authorization;
+
+namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.Register;
+
+public class RegisterCommandAuthorizer :
+ AbstractRequestAuthorizer
+{
+ public override void BuildPolicy(RegisterCommand request)
+ {
+ UseRequirement(new AllowAllRequirement());
+ }
+}
diff --git a/src/Application/Authentication/Commands/Register/RegisterCommandHandler.cs b/src/Application/Authentication/Commands/Register/RegisterCommandHandler.cs
index 99ca0f1..f84b3e5 100644
--- a/src/Application/Authentication/Commands/Register/RegisterCommandHandler.cs
+++ b/src/Application/Authentication/Commands/Register/RegisterCommandHandler.cs
@@ -1,21 +1,83 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using System.Security.Cryptography;
+using System.Text;
+using cuqmbr.TravelGuide.Application.Common.Exceptions;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Entities;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR;
namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.Register;
public class RegisterCommandHandler : IRequestHandler
{
- private readonly AuthenticationService _authenticationService;
+ private readonly IReadOnlyCollection DefaultRoles =
+ new IdentityRole[] { IdentityRole.User };
- public RegisterCommandHandler(AuthenticationService authenticationService)
+ private readonly UnitOfWork _unitOfWork;
+ private readonly PasswordHasherService _passwordHasher;
+
+ public RegisterCommandHandler(UnitOfWork unitOfWork,
+ PasswordHasherService passwordHasher)
{
- _authenticationService = authenticationService;
+ _unitOfWork = unitOfWork;
+ _passwordHasher = passwordHasher;
}
- public async Task Handle(
- RegisterCommand request, CancellationToken cancellationToken)
+ public async Task Handle(RegisterCommand request,
+ CancellationToken cancellationToken)
{
- await _authenticationService.RegisterAsync(
- request.Email, request.Password, cancellationToken);
+ var datastoreAccount = await _unitOfWork.AccountRepository
+ .GetOneAsync(
+ e =>
+ e.Email == request.Email ||
+ e.Username == request.Username,
+ cancellationToken);
+
+ if (datastoreAccount != null)
+ {
+ throw new RegistrationException(
+ "User with given email or username already registered.");
+ }
+
+
+ var defaultRoleIds = (await _unitOfWork.RoleRepository
+ .GetPageAsync(
+ r => DefaultRoles.Contains(r.Value),
+ 1, DefaultRoles.Count, cancellationToken))
+ .Items
+ .Select(r => r.Id);
+
+
+ var password = Encoding.UTF8.GetBytes(request.Password);
+
+ var salt = RandomNumberGenerator.GetBytes(128 / 8);
+ var hash = await _passwordHasher
+ .HashAsync(password, salt, cancellationToken);
+
+ var saltBase64 = Convert.ToBase64String(salt);
+ var hashBase64 = Convert.ToBase64String(hash);
+
+
+ var newAccount = new Account
+ {
+ Username = request.Username,
+ Email = request.Email,
+ PasswordHash = hashBase64,
+ PasswordSalt = saltBase64,
+ AccountRoles = defaultRoleIds.Select(id =>
+ new AccountRole()
+ {
+ RoleId = id
+ })
+ .ToArray()
+ };
+
+
+ await _unitOfWork.AccountRepository
+ .AddOneAsync(newAccount, cancellationToken);
+
+ await _unitOfWork.SaveAsync(cancellationToken);
+ _unitOfWork.Dispose();
}
}
diff --git a/src/Application/Authentication/Commands/Register/RegisterCommandValidator.cs b/src/Application/Authentication/Commands/Register/RegisterCommandValidator.cs
index 13afc23..f009284 100644
--- a/src/Application/Authentication/Commands/Register/RegisterCommandValidator.cs
+++ b/src/Application/Authentication/Commands/Register/RegisterCommandValidator.cs
@@ -1,31 +1,54 @@
+using cuqmbr.TravelGuide.Application.Common.FluentValidation;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
+using Microsoft.Extensions.Localization;
namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.Register;
public class RegisterCommandValidator : AbstractValidator
{
- public RegisterCommandValidator()
+ public RegisterCommandValidator(
+ IStringLocalizer localizer,
+ SessionCultureService cultureService)
{
+ RuleFor(v => v.Username)
+ .NotEmpty()
+ .WithMessage(localizer["FluentValidation.NotEmpty"])
+ .MinimumLength(1)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.MinimumLength"],
+ 1))
+ .MaximumLength(32)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.MaximumLength"],
+ 32))
+ .IsUsername()
+ .WithMessage(localizer["FluentValidation.IsUsername"]);
+
RuleFor(v => v.Email)
.NotEmpty()
- .WithMessage("Email address is required.")
- .Matches(@"\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b")
- .WithMessage("Email address is invalid.");
+ .WithMessage(localizer["FluentValidation.NotEmpty"])
+ .IsEmail()
+ .WithMessage(localizer["FluentValidation.IsEmail"]);
RuleFor(v => v.Password)
.NotEmpty()
- .WithMessage("Password is required.")
+ .WithMessage(localizer["FluentValidation.NotEmpty"])
.MinimumLength(8)
- .WithMessage("Password must be at least 8 characters long.")
- .MaximumLength(64)
- .WithMessage("Password must be at most 64 characters long.")
- .Matches(@"(?=.*[A-Z]).*")
- .WithMessage("Password must contain at least one uppercase letter.")
- .Matches(@"(?=.*[a-z]).*")
- .WithMessage("Password must contain at least one lowercase letter.")
- .Matches(@"(?=.*[\d]).*")
- .WithMessage("Password must contain at least one digit.")
- .Matches(@"(?=.*[!@#$%^&*()]).*")
- .WithMessage("Password must contain at least one of the following special charactters: !@#$%^&*().");
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.MinimumLength"],
+ 8))
+ .MaximumLength(256)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.MaximumLength"],
+ 256));
}
}
diff --git a/src/Application/Authentication/Commands/RenewAccessToken/RenewAccessTokenCommandAuthorizer.cs b/src/Application/Authentication/Commands/RenewAccessToken/RenewAccessTokenCommandAuthorizer.cs
index e5237e1..3d102fc 100644
--- a/src/Application/Authentication/Commands/RenewAccessToken/RenewAccessTokenCommandAuthorizer.cs
+++ b/src/Application/Authentication/Commands/RenewAccessToken/RenewAccessTokenCommandAuthorizer.cs
@@ -1,5 +1,5 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+// using cuqmbr.TravelGuide.Application.Common.Services;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.RenewAccessToken;
@@ -7,18 +7,19 @@ namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.RenewAccessToken
public class RenewAccessTokenCommandAuthorizer :
AbstractRequestAuthorizer
{
- private readonly SessionUserService _sessionUserService;
-
- public RenewAccessTokenCommandAuthorizer(SessionUserService currentUserService)
- {
- _sessionUserService = currentUserService;
- }
+ // private readonly SessionUserService _sessionUserService;
+ //
+ // public RenewAccessTokenCommandAuthorizer(SessionUserService currentUserService)
+ // {
+ // _sessionUserService = currentUserService;
+ // }
public override void BuildPolicy(RenewAccessTokenCommand request)
{
- UseRequirement(new MustBeAuthenticatedRequirement
- {
- IsAuthenticated = _sessionUserService.IsAuthenticated
- });
+ UseRequirement(new AllowAllRequirement());
+ // UseRequirement(new MustBeAuthenticatedRequirement
+ // {
+ // IsAuthenticated = _sessionUserService.IsAuthenticated
+ // });
}
}
diff --git a/src/Application/Authentication/Commands/RenewAccessToken/RenewAccessTokenCommandHandler.cs b/src/Application/Authentication/Commands/RenewAccessToken/RenewAccessTokenCommandHandler.cs
index 0cb9016..b6f47c4 100644
--- a/src/Application/Authentication/Commands/RenewAccessToken/RenewAccessTokenCommandHandler.cs
+++ b/src/Application/Authentication/Commands/RenewAccessToken/RenewAccessTokenCommandHandler.cs
@@ -1,22 +1,95 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using System.IdentityModel.Tokens.Jwt;
+using System.Security.Claims;
+using System.Text;
+using cuqmbr.TravelGuide.Application.Common.Exceptions;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
+using cuqmbr.TravelGuide.Domain.Entities;
using MediatR;
+using Microsoft.Extensions.Options;
+using Microsoft.IdentityModel.Tokens;
namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.RenewAccessToken;
public class RenewAccessTokenCommandHandler :
IRequestHandler
{
- private readonly AuthenticationService _authenticationService;
+ private readonly UnitOfWork _unitOfWork;
+ private readonly JsonWebTokenConfigurationOptions _jwtConfiguration;
- public RenewAccessTokenCommandHandler(AuthenticationService authenticationService)
+ public RenewAccessTokenCommandHandler(UnitOfWork unitOfWork,
+ IOptions configurationOptions)
{
- _authenticationService = authenticationService;
+ _unitOfWork = unitOfWork;
+ _jwtConfiguration = configurationOptions.Value.JsonWebToken;
}
public async Task Handle(
RenewAccessTokenCommand request, CancellationToken cancellationToken)
{
- return await _authenticationService.RenewAccessTokenAsync(
- request.RefreshToken, cancellationToken);
+ var refreshToken = (await _unitOfWork.RefreshTokenRepository
+ .GetOneAsync(e => e.Value == request.RefreshToken,
+ cancellationToken));
+
+ if (refreshToken == null)
+ {
+ throw new AuthenticationException($"Refresh token was not found.");
+ }
+
+ if (!refreshToken.IsActive)
+ {
+ throw new AuthenticationException("Refresh token is inactive.");
+ }
+
+ var account = await _unitOfWork.AccountRepository.GetOneAsync(
+ a => a.RefreshTokens.Contains(refreshToken),
+ a => a.AccountRoles, cancellationToken);
+
+ var jwtSecurityToken = await CreateJwtAsync(account, cancellationToken);
+ var accessToken = new JwtSecurityTokenHandler().WriteToken(jwtSecurityToken);
+
+ return new TokensModel(accessToken, refreshToken.Value);
+ }
+
+ private async Task CreateJwtAsync(
+ Account account, CancellationToken cancellationToken)
+ {
+ var roleIds = account.AccountRoles.Select(ar => ar.RoleId);
+
+ var roles = (await _unitOfWork.RoleRepository
+ .GetPageAsync(
+ r => roleIds.Contains(r.Id),
+ 1, roleIds.Count(), cancellationToken))
+ .Items.Select(r => r.Value);
+
+ var roleClaims = new List();
+ foreach (var role in roles)
+ {
+ roleClaims.Add(new Claim("roles", role.Name));
+ }
+
+ var claims = new List()
+ {
+ new Claim(JwtRegisteredClaimNames.Sub, account.Guid.ToString()),
+ new Claim(JwtRegisteredClaimNames.Nickname, account.Username),
+ new Claim(JwtRegisteredClaimNames.Email, account.Email)
+ }
+ .Union(roleClaims);
+
+ var expirationDateTimeUtc = DateTime.UtcNow.Add(
+ _jwtConfiguration.AccessTokenValidity);
+
+ var symmetricSecurityKey = new SymmetricSecurityKey(
+ Encoding.UTF8.GetBytes(_jwtConfiguration.IssuerSigningKey));
+ var signingCredentials = new SigningCredentials(
+ symmetricSecurityKey, SecurityAlgorithms.HmacSha256);
+
+ var jwtSecurityToken = new JwtSecurityToken(
+ issuer: _jwtConfiguration.Issuer,
+ audience: _jwtConfiguration.Audience,
+ claims: claims,
+ expires: expirationDateTimeUtc,
+ signingCredentials: signingCredentials);
+
+ return jwtSecurityToken;
}
}
diff --git a/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommand.cs b/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommand.cs
deleted file mode 100644
index 93f2031..0000000
--- a/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommand.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-using MediatR;
-
-namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RenewAccessTokenWithCookie;
-
-public record RenewAccessTokenWithCookieCommand : IRequest { }
diff --git a/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandAuthorizer.cs b/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandAuthorizer.cs
deleted file mode 100644
index 481c916..0000000
--- a/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandAuthorizer.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using MediatR.Behaviors.Authorization;
-
-namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RenewAccessTokenWithCookie;
-
-public class RenewAccessTokenWithCookieCommandAuthorizer :
- AbstractRequestAuthorizer
-{
- private readonly SessionUserService _sessionUserService;
-
- public RenewAccessTokenWithCookieCommandAuthorizer(
- SessionUserService currentUserService)
- {
- _sessionUserService = currentUserService;
- }
-
- public override void BuildPolicy(RenewAccessTokenWithCookieCommand request)
- {
- UseRequirement(new MustBeAuthenticatedRequirement
- {
- IsAuthenticated = _sessionUserService.IsAuthenticated
- });
- }
-}
diff --git a/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandHandler.cs b/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandHandler.cs
deleted file mode 100644
index 797b289..0000000
--- a/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandHandler.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using MediatR;
-
-namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RenewAccessTokenWithCookie;
-
-public class RenewAccessTokenWithCookieCommandHandler :
- IRequestHandler
-{
- private readonly AuthenticationService _authenticationService;
- private readonly SessionUserService _sessionUserService;
-
- public RenewAccessTokenWithCookieCommandHandler(
- AuthenticationService authenticationService,
- SessionUserService sessionUserService)
- {
- _authenticationService = authenticationService;
- _sessionUserService = sessionUserService;
- }
-
- public async Task Handle(
- RenewAccessTokenWithCookieCommand request,
- CancellationToken cancellationToken)
- {
- return await _authenticationService.RenewAccessTokenAsync(
- _sessionUserService.RefreshToken, cancellationToken);
- }
-}
diff --git a/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandValidator.cs b/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandValidator.cs
deleted file mode 100644
index a49e1ef..0000000
--- a/src/Application/Authentication/Commands/RenewAccessTokenWithCookieWithCookie/RenewAccessTokenWithCookieCommandValidator.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FluentValidation;
-
-namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RenewAccessTokenWithCookie;
-
-public class RenewAccessTokenWithCookieCommandValidator :
- AbstractValidator
-{
- public RenewAccessTokenWithCookieCommandValidator() { }
-}
diff --git a/src/Application/Authentication/Commands/RevokeRefreshToken/RevokeRefreshTokenCommandAuthorizer.cs b/src/Application/Authentication/Commands/RevokeRefreshToken/RevokeRefreshTokenCommandAuthorizer.cs
index d298795..c0fe1d9 100644
--- a/src/Application/Authentication/Commands/RevokeRefreshToken/RevokeRefreshTokenCommandAuthorizer.cs
+++ b/src/Application/Authentication/Commands/RevokeRefreshToken/RevokeRefreshTokenCommandAuthorizer.cs
@@ -1,5 +1,4 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.RevokeRefreshToken;
@@ -7,18 +6,8 @@ namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.RevokeRefreshTok
public class RevokeRefreshTokenCommandAuthorizer :
AbstractRequestAuthorizer
{
- private readonly SessionUserService _sessionUserService;
-
- public RevokeRefreshTokenCommandAuthorizer(SessionUserService currentUserService)
- {
- _sessionUserService = currentUserService;
- }
-
public override void BuildPolicy(RevokeRefreshTokenCommand request)
{
- UseRequirement(new MustBeAuthenticatedRequirement
- {
- IsAuthenticated = _sessionUserService.IsAuthenticated
- });
+ UseRequirement(new AllowAllRequirement());
}
}
diff --git a/src/Application/Authentication/Commands/RevokeRefreshToken/RevokeRefreshTokenCommandHandler.cs b/src/Application/Authentication/Commands/RevokeRefreshToken/RevokeRefreshTokenCommandHandler.cs
index 1c0f322..2e9dee5 100644
--- a/src/Application/Authentication/Commands/RevokeRefreshToken/RevokeRefreshTokenCommandHandler.cs
+++ b/src/Application/Authentication/Commands/RevokeRefreshToken/RevokeRefreshTokenCommandHandler.cs
@@ -1,4 +1,5 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Exceptions;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using MediatR;
namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.RevokeRefreshToken;
@@ -6,17 +7,36 @@ namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands.RevokeRefreshTok
public class RevokeRefreshTokenCommandHandler :
IRequestHandler
{
- private readonly AuthenticationService _authenticationService;
+ private readonly UnitOfWork _unitOfWork;
- public RevokeRefreshTokenCommandHandler(AuthenticationService authenticationService)
+ public RevokeRefreshTokenCommandHandler(UnitOfWork unitOfWork)
{
- _authenticationService = authenticationService;
+ _unitOfWork = unitOfWork;
}
public async Task Handle(
RevokeRefreshTokenCommand request, CancellationToken cancellationToken)
{
- await _authenticationService.RevokeRefreshTokenAsync(
- request.RefreshToken, cancellationToken);
+ var refreshToken = (await _unitOfWork.RefreshTokenRepository
+ .GetOneAsync(e => e.Value == request.RefreshToken,
+ cancellationToken));
+
+ if (refreshToken == null)
+ {
+ throw new AuthenticationException("Invalid refreshToken");
+ }
+
+ if (!refreshToken.IsActive)
+ {
+ throw new AuthenticationException("RefreshToken already revoked");
+ }
+
+ refreshToken.RevocationTime = DateTimeOffset.UtcNow;
+
+ await _unitOfWork.RefreshTokenRepository
+ .UpdateOneAsync(refreshToken, cancellationToken);
+
+ await _unitOfWork.SaveAsync(cancellationToken);
+ _unitOfWork.Dispose();
}
}
diff --git a/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommand.cs b/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommand.cs
deleted file mode 100644
index f277cc8..0000000
--- a/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommand.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-using MediatR;
-
-namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RevokeRefreshTokenWithCookie;
-
-public record RevokeRefreshTokenWithCookieCommand : IRequest { }
diff --git a/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandAuthorizer.cs b/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandAuthorizer.cs
deleted file mode 100644
index eb2f8e2..0000000
--- a/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandAuthorizer.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using MediatR.Behaviors.Authorization;
-
-namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RevokeRefreshTokenWithCookie;
-
-public class RevokeRefreshTokenWithCookieCommandAuthorizer :
- AbstractRequestAuthorizer
-{
- private readonly SessionUserService _sessionUserService;
-
- public RevokeRefreshTokenWithCookieCommandAuthorizer(
- SessionUserService currentUserService)
- {
- _sessionUserService = currentUserService;
- }
-
- public override void BuildPolicy(RevokeRefreshTokenWithCookieCommand request)
- {
- UseRequirement(new MustBeAuthenticatedRequirement
- {
- IsAuthenticated = _sessionUserService.IsAuthenticated
- });
- }
-}
diff --git a/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandHandler.cs b/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandHandler.cs
deleted file mode 100644
index 27a8339..0000000
--- a/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandHandler.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using MediatR;
-
-namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RevokeRefreshTokenWithCookie;
-
-public class RevokeRefreshTokenWithCookieCommandHandler :
- IRequestHandler
-{
- private readonly AuthenticationService _authenticationService;
- private readonly SessionUserService _sessionUserService;
-
- public RevokeRefreshTokenWithCookieCommandHandler(
- AuthenticationService authenticationService,
- SessionUserService sessionUserService)
- {
- _authenticationService = authenticationService;
- _sessionUserService = sessionUserService;
- }
-
- public async Task Handle(
- RevokeRefreshTokenWithCookieCommand request,
- CancellationToken cancellationToken)
- {
- await _authenticationService.RevokeRefreshTokenAsync(
- _sessionUserService.RefreshToken, cancellationToken);
- }
-}
diff --git a/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandValidator.cs b/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandValidator.cs
deleted file mode 100644
index c378206..0000000
--- a/src/Application/Authentication/Commands/RevokeRefreshTokenWithCookie/RevokeRefreshTokenWithCookieCommandValidator.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FluentValidation;
-
-namespace cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RevokeRefreshTokenWithCookie;
-
-public class RevokeRefreshTokenWithCookieCommandValidator :
- AbstractValidator
-{
- public RevokeRefreshTokenWithCookieCommandValidator() { }
-}
diff --git a/src/Application/Authentication/Queries/Login/LoginQuery.cs b/src/Application/Authentication/Queries/Login/LoginQuery.cs
index 905347c..3a2c4dd 100644
--- a/src/Application/Authentication/Queries/Login/LoginQuery.cs
+++ b/src/Application/Authentication/Queries/Login/LoginQuery.cs
@@ -4,7 +4,7 @@ namespace cuqmbr.TravelGuide.Application.Authenticaion.Queries.Login;
public record LoginQuery : IRequest
{
- public string Email { get; set; }
+ public string EmailOrUsername { get; set; }
public string Password { get; set; }
}
diff --git a/src/Application/Authentication/Queries/Login/LoginQueryAuthorizer.cs b/src/Application/Authentication/Queries/Login/LoginQueryAuthorizer.cs
new file mode 100644
index 0000000..eb5ab38
--- /dev/null
+++ b/src/Application/Authentication/Queries/Login/LoginQueryAuthorizer.cs
@@ -0,0 +1,12 @@
+using cuqmbr.TravelGuide.Application.Common.Authorization;
+using MediatR.Behaviors.Authorization;
+
+namespace cuqmbr.TravelGuide.Application.Authenticaion.Queries.Login;
+
+public class LoginQueryAuthorizer : AbstractRequestAuthorizer
+{
+ public override void BuildPolicy(LoginQuery request)
+ {
+ UseRequirement(new AllowAllRequirement());
+ }
+}
diff --git a/src/Application/Authentication/Queries/Login/LoginQueryHandler.cs b/src/Application/Authentication/Queries/Login/LoginQueryHandler.cs
index 693a5bb..00e360b 100644
--- a/src/Application/Authentication/Queries/Login/LoginQueryHandler.cs
+++ b/src/Application/Authentication/Queries/Login/LoginQueryHandler.cs
@@ -1,21 +1,140 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using System.IdentityModel.Tokens.Jwt;
+using System.Security.Claims;
+using System.Security.Cryptography;
+using System.Text;
+using cuqmbr.TravelGuide.Application.Common.Exceptions;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Entities;
using MediatR;
+using Microsoft.Extensions.Options;
+using Microsoft.IdentityModel.Tokens;
namespace cuqmbr.TravelGuide.Application.Authenticaion.Queries.Login;
public class LoginQueryHandler : IRequestHandler
{
- private readonly AuthenticationService _authenticationService;
+ private readonly UnitOfWork _unitOfWork;
+ private readonly PasswordHasherService _passwordHasher;
+ private readonly JsonWebTokenConfigurationOptions _jwtConfiguration;
- public LoginQueryHandler(AuthenticationService authenticationService)
+ public LoginQueryHandler(UnitOfWork unitOfWork,
+ PasswordHasherService passwordHasher,
+ IOptions configurationOptions)
{
- _authenticationService = authenticationService;
+ _unitOfWork = unitOfWork;
+ _passwordHasher = passwordHasher;
+ _jwtConfiguration = configurationOptions.Value.JsonWebToken;
}
public async Task Handle(
LoginQuery request, CancellationToken cancellationToken)
{
- return await _authenticationService.LoginAsync(
- request.Email, request.Password, cancellationToken);
+ var account = await _unitOfWork.AccountRepository
+ .GetOneAsync(
+ a =>
+ a.Email == request.EmailOrUsername ||
+ a.Username == request.EmailOrUsername,
+ a => a.AccountRoles, cancellationToken);
+
+ if (account == null)
+ {
+ throw new LoginException("No users registered with given email.");
+ }
+
+ var hash = Convert.FromBase64String(account.PasswordHash);
+ var salt = Convert.FromBase64String(account.PasswordSalt);
+ var password = Encoding.UTF8.GetBytes(request.Password);
+
+ var isValidPassword = await _passwordHasher
+ .IsValidHashAsync(hash, password, salt, cancellationToken);
+
+ if (!isValidPassword)
+ {
+ throw new LoginException("Given password is incorrect.");
+ }
+
+ var jwtSecurityToken = await CreateJwtAsync(account, cancellationToken);
+ var accessToken = new JwtSecurityTokenHandler().WriteToken(jwtSecurityToken);
+
+ var refreshToken = (await _unitOfWork.RefreshTokenRepository
+ .GetPageAsync(
+ e =>
+ e.AccountId == account.Id &&
+ e.RevocationTime == null &&
+ e.ExpirationTime > DateTimeOffset.UtcNow,
+ 1, int.MaxValue, cancellationToken))
+ .Items.FirstOrDefault();
+
+ if (refreshToken == null)
+ {
+ refreshToken = CreateRefreshToken();
+ refreshToken.AccountId = account.Id;
+
+ await _unitOfWork.RefreshTokenRepository
+ .AddOneAsync(refreshToken, cancellationToken);
+ }
+
+ await _unitOfWork.SaveAsync(cancellationToken);
+ _unitOfWork.Dispose();
+
+ return new TokensModel(accessToken, refreshToken.Value);
+ }
+
+ private async Task CreateJwtAsync(
+ Account account, CancellationToken cancellationToken)
+ {
+ var roleIds = account.AccountRoles.Select(ar => ar.RoleId);
+
+ var roles = (await _unitOfWork.RoleRepository
+ .GetPageAsync(
+ r => roleIds.Contains(r.Id),
+ 1, roleIds.Count(), cancellationToken))
+ .Items.Select(r => r.Value);
+
+ var roleClaims = new List();
+ foreach (var role in roles)
+ {
+ roleClaims.Add(new Claim("roles", role.Name));
+ }
+
+ var claims = new List()
+ {
+ new Claim(JwtRegisteredClaimNames.Sub, account.Guid.ToString()),
+ new Claim(JwtRegisteredClaimNames.Nickname, account.Username),
+ new Claim(JwtRegisteredClaimNames.Email, account.Email)
+ }
+ .Union(roleClaims);
+
+ var expirationDateTimeUtc = DateTime.UtcNow.Add(
+ _jwtConfiguration.AccessTokenValidity);
+
+ var symmetricSecurityKey = new SymmetricSecurityKey(
+ Encoding.UTF8.GetBytes(_jwtConfiguration.IssuerSigningKey));
+ var signingCredentials = new SigningCredentials(
+ symmetricSecurityKey, SecurityAlgorithms.HmacSha256);
+
+ var jwtSecurityToken = new JwtSecurityToken(
+ issuer: _jwtConfiguration.Issuer,
+ audience: _jwtConfiguration.Audience,
+ claims: claims,
+ expires: expirationDateTimeUtc,
+ signingCredentials: signingCredentials);
+
+ return jwtSecurityToken;
+ }
+
+ private RefreshToken CreateRefreshToken()
+ {
+ var token = RandomNumberGenerator.GetBytes(128 / 8);
+
+ return new RefreshToken
+ {
+ Guid = Guid.NewGuid(),
+ Value = Convert.ToBase64String(token),
+ CreationTime = DateTimeOffset.UtcNow,
+ ExpirationTime = DateTimeOffset.UtcNow.Add(
+ _jwtConfiguration.RefreshTokenValidity)
+ };
}
}
diff --git a/src/Application/Authentication/Queries/Login/LoginQueryValidator.cs b/src/Application/Authentication/Queries/Login/LoginQueryValidator.cs
index 9f3fb38..7a0ed0b 100644
--- a/src/Application/Authentication/Queries/Login/LoginQueryValidator.cs
+++ b/src/Application/Authentication/Queries/Login/LoginQueryValidator.cs
@@ -1,15 +1,18 @@
using FluentValidation;
+using Microsoft.Extensions.Localization;
namespace cuqmbr.TravelGuide.Application.Authenticaion.Queries.Login;
public class LoginQueryValidator : AbstractValidator
{
- public LoginQueryValidator()
+ public LoginQueryValidator(IStringLocalizer localizer)
{
- RuleFor(v => v.Email)
- .NotEmpty().WithMessage("Email address is required.");
+ RuleFor(v => v.EmailOrUsername)
+ .NotEmpty()
+ .WithMessage(localizer["FluentValidation.NotEmpty"]);
RuleFor(v => v.Password)
- .NotEmpty().WithMessage("Password is required.");
+ .NotEmpty()
+ .WithMessage(localizer["FluentValidation.NotEmpty"]);
}
}
diff --git a/src/Application/Buses/Commands/AddBus/AddBusCommandAuthorizer.cs b/src/Application/Buses/Commands/AddBus/AddBusCommandAuthorizer.cs
index 60a0581..5e16639 100644
--- a/src/Application/Buses/Commands/AddBus/AddBusCommandAuthorizer.cs
+++ b/src/Application/Buses/Commands/AddBus/AddBusCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Buses.Commands.AddBus;
diff --git a/src/Application/Buses/Commands/AddBus/AddBusCommandHandler.cs b/src/Application/Buses/Commands/AddBus/AddBusCommandHandler.cs
index 346bd4b..3d5c276 100644
--- a/src/Application/Buses/Commands/AddBus/AddBusCommandHandler.cs
+++ b/src/Application/Buses/Commands/AddBus/AddBusCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Buses/Commands/AddBus/AddBusCommandValidator.cs b/src/Application/Buses/Commands/AddBus/AddBusCommandValidator.cs
index 084cfcc..f16532a 100644
--- a/src/Application/Buses/Commands/AddBus/AddBusCommandValidator.cs
+++ b/src/Application/Buses/Commands/AddBus/AddBusCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Buses/Commands/DeleteBus/DeleteBusCommandAuthorizer.cs b/src/Application/Buses/Commands/DeleteBus/DeleteBusCommandAuthorizer.cs
index 2f61edc..f5858c7 100644
--- a/src/Application/Buses/Commands/DeleteBus/DeleteBusCommandAuthorizer.cs
+++ b/src/Application/Buses/Commands/DeleteBus/DeleteBusCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Buses.Commands.DeleteBus;
diff --git a/src/Application/Buses/Commands/DeleteBus/DeleteBusCommandHandler.cs b/src/Application/Buses/Commands/DeleteBus/DeleteBusCommandHandler.cs
index f226338..1755ddd 100644
--- a/src/Application/Buses/Commands/DeleteBus/DeleteBusCommandHandler.cs
+++ b/src/Application/Buses/Commands/DeleteBus/DeleteBusCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Buses.Commands.DeleteBus;
diff --git a/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandAuthorizer.cs b/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandAuthorizer.cs
index 17201fa..1b05021 100644
--- a/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandAuthorizer.cs
+++ b/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Buses.Commands.UpdateBus;
diff --git a/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandHandler.cs b/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandHandler.cs
index 2360617..64e74b8 100644
--- a/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandHandler.cs
+++ b/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandValidator.cs b/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandValidator.cs
index 74c6b26..4a11102 100644
--- a/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandValidator.cs
+++ b/src/Application/Buses/Commands/UpdateBus/UpdateBusCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Buses/Queries/GetBus/GetBusQueryAuthorizer.cs b/src/Application/Buses/Queries/GetBus/GetBusQueryAuthorizer.cs
index 372b46e..a22724c 100644
--- a/src/Application/Buses/Queries/GetBus/GetBusQueryAuthorizer.cs
+++ b/src/Application/Buses/Queries/GetBus/GetBusQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Buses.Queries.GetBus;
diff --git a/src/Application/Buses/Queries/GetBus/GetBusQueryHandler.cs b/src/Application/Buses/Queries/GetBus/GetBusQueryHandler.cs
index b1fc747..55c1b86 100644
--- a/src/Application/Buses/Queries/GetBus/GetBusQueryHandler.cs
+++ b/src/Application/Buses/Queries/GetBus/GetBusQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryAuthorizer.cs b/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryAuthorizer.cs
index f51a43c..8c26e31 100644
--- a/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryAuthorizer.cs
+++ b/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Buses.Queries.GetBusesPage;
diff --git a/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryHandler.cs b/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryHandler.cs
index 28fe46f..9d29d12 100644
--- a/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryHandler.cs
+++ b/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryValidator.cs b/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryValidator.cs
index 7ab1118..432f9e3 100644
--- a/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryValidator.cs
+++ b/src/Application/Buses/Queries/GetBusesPage/GetBusesPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Cities/Commands/AddCity/AddCityCommandAuthorizer.cs b/src/Application/Cities/Commands/AddCity/AddCityCommandAuthorizer.cs
index 1122f5f..18d5425 100644
--- a/src/Application/Cities/Commands/AddCity/AddCityCommandAuthorizer.cs
+++ b/src/Application/Cities/Commands/AddCity/AddCityCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Cities.Commands.AddCity;
diff --git a/src/Application/Cities/Commands/AddCity/AddCityCommandHandler.cs b/src/Application/Cities/Commands/AddCity/AddCityCommandHandler.cs
index 51584b4..13d7708 100644
--- a/src/Application/Cities/Commands/AddCity/AddCityCommandHandler.cs
+++ b/src/Application/Cities/Commands/AddCity/AddCityCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Cities/Commands/AddCity/AddCityCommandValidator.cs b/src/Application/Cities/Commands/AddCity/AddCityCommandValidator.cs
index 6b20606..4dd216c 100644
--- a/src/Application/Cities/Commands/AddCity/AddCityCommandValidator.cs
+++ b/src/Application/Cities/Commands/AddCity/AddCityCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Cities/Commands/DeleteCity/DeleteCityCommandAuthorizer.cs b/src/Application/Cities/Commands/DeleteCity/DeleteCityCommandAuthorizer.cs
index ed62a53..f966a4e 100644
--- a/src/Application/Cities/Commands/DeleteCity/DeleteCityCommandAuthorizer.cs
+++ b/src/Application/Cities/Commands/DeleteCity/DeleteCityCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Cities.Commands.DeleteCity;
diff --git a/src/Application/Cities/Commands/DeleteCity/DeleteCityCommandHandler.cs b/src/Application/Cities/Commands/DeleteCity/DeleteCityCommandHandler.cs
index 700334d..c5ebf61 100644
--- a/src/Application/Cities/Commands/DeleteCity/DeleteCityCommandHandler.cs
+++ b/src/Application/Cities/Commands/DeleteCity/DeleteCityCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Cities.Commands.DeleteCity;
diff --git a/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandAuthorizer.cs b/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandAuthorizer.cs
index ed1e198..263feaa 100644
--- a/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandAuthorizer.cs
+++ b/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Cities.Commands.UpdateCity;
diff --git a/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandHandler.cs b/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandHandler.cs
index 5fecbc5..8e71fb3 100644
--- a/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandHandler.cs
+++ b/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandValidator.cs b/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandValidator.cs
index bdc49c0..6d1ef78 100644
--- a/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandValidator.cs
+++ b/src/Application/Cities/Commands/UpdateCity/UpdateCityCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryAuthorizer.cs b/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryAuthorizer.cs
index 84872fe..e52cd0d 100644
--- a/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryAuthorizer.cs
+++ b/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Cities.Queries.GetCitiesPage;
diff --git a/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryHandler.cs b/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryHandler.cs
index 3d4d568..f3b45af 100644
--- a/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryHandler.cs
+++ b/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryValidator.cs b/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryValidator.cs
index 53e5264..9bc82fa 100644
--- a/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryValidator.cs
+++ b/src/Application/Cities/Queries/GetCitiesPage/GetCitiesPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Cities/Queries/GetCity/GetCityQueryAuthorizer.cs b/src/Application/Cities/Queries/GetCity/GetCityQueryAuthorizer.cs
index 55f927d..875847f 100644
--- a/src/Application/Cities/Queries/GetCity/GetCityQueryAuthorizer.cs
+++ b/src/Application/Cities/Queries/GetCity/GetCityQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Cities.Queries.GetCity;
diff --git a/src/Application/Cities/Queries/GetCity/GetCityQueryHandler.cs b/src/Application/Cities/Queries/GetCity/GetCityQueryHandler.cs
index 68e3aec..49827e2 100644
--- a/src/Application/Cities/Queries/GetCity/GetCityQueryHandler.cs
+++ b/src/Application/Cities/Queries/GetCity/GetCityQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/Common/Authorization/MustBeInRolesRequirement.cs b/src/Application/Common/Authorization/MustBeInRolesRequirement.cs
index e1368d1..8035dd0 100644
--- a/src/Application/Common/Authorization/MustBeInRolesRequirement.cs
+++ b/src/Application/Common/Authorization/MustBeInRolesRequirement.cs
@@ -1,6 +1,6 @@
using MediatR.Behaviors.Authorization;
using Microsoft.Extensions.Localization;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Domain.Enums;
namespace cuqmbr.TravelGuide.Application.Common.Authorization;
diff --git a/src/Application/Common/FluentValidation/CustomValidators.cs b/src/Application/Common/FluentValidation/CustomValidators.cs
index f7b1de1..0dfbce8 100644
--- a/src/Application/Common/FluentValidation/CustomValidators.cs
+++ b/src/Application/Common/FluentValidation/CustomValidators.cs
@@ -4,6 +4,14 @@ namespace cuqmbr.TravelGuide.Application.Common.FluentValidation;
public static class CustomValidators
{
+ public static IRuleBuilderOptions IsUsername(
+ this IRuleBuilder ruleBuilder)
+ {
+ return
+ ruleBuilder
+ .Matches(@"^[a-z0-9-_.]*$");
+ }
+
// According to RFC 5321.
public static IRuleBuilderOptions IsEmail(
this IRuleBuilder ruleBuilder)
diff --git a/src/Application/Common/Interfaces/Services/AuthenticationService.cs b/src/Application/Common/Interfaces/Services/AuthenticationService.cs
deleted file mode 100644
index 6f8932b..0000000
--- a/src/Application/Common/Interfaces/Services/AuthenticationService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using cuqmbr.TravelGuide.Application.Authenticaion;
-
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-
-public interface AuthenticationService
-{
- Task RegisterAsync(string email, string password,
- CancellationToken cancellationToken);
-
- Task LoginAsync(string email, string password,
- CancellationToken cancellationToken);
-
- Task RenewAccessTokenAsync(string refreshToken,
- CancellationToken cancellationToken);
-
- Task RevokeRefreshTokenAsync(string refreshToken,
- CancellationToken cancellationToken);
-}
diff --git a/src/Application/Common/Interfaces/Services/SessionUserService.cs b/src/Application/Common/Interfaces/Services/SessionUserService.cs
deleted file mode 100644
index 0ffb78d..0000000
--- a/src/Application/Common/Interfaces/Services/SessionUserService.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using cuqmbr.TravelGuide.Application.Common.Models;
-
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-
-public interface SessionUserService
-{
- public int? Id { get; }
-
- public Guid? Uuid { get; }
-
- public string? Email { get; }
-
- public ICollection Roles { get; }
-
-
- public bool IsAuthenticated => Id != null;
-
-
- public string? AccessToken { get; }
-
- public string? RefreshToken { get; }
-}
diff --git a/src/Application/Common/Mappings/Resolvers/DateTimeOffsetResolver.cs b/src/Application/Common/Mappings/Resolvers/DateTimeOffsetResolver.cs
index 56423e8..8f7797f 100644
--- a/src/Application/Common/Mappings/Resolvers/DateTimeOffsetResolver.cs
+++ b/src/Application/Common/Mappings/Resolvers/DateTimeOffsetResolver.cs
@@ -1,5 +1,5 @@
using AutoMapper;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
namespace cuqmbr.TravelGuide.Application.Common.Mappings.Resolvers;
diff --git a/src/Application/Common/Persistence/Repositories/AccountRepository.cs b/src/Application/Common/Persistence/Repositories/AccountRepository.cs
new file mode 100644
index 0000000..57ab40e
--- /dev/null
+++ b/src/Application/Common/Persistence/Repositories/AccountRepository.cs
@@ -0,0 +1,5 @@
+using cuqmbr.TravelGuide.Domain.Entities;
+
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
+
+public interface AccountRepository : BaseRepository { }
diff --git a/src/Application/Common/Persistence/Repositories/AccountRoleRepository.cs b/src/Application/Common/Persistence/Repositories/AccountRoleRepository.cs
new file mode 100644
index 0000000..42ce1c1
--- /dev/null
+++ b/src/Application/Common/Persistence/Repositories/AccountRoleRepository.cs
@@ -0,0 +1,5 @@
+using cuqmbr.TravelGuide.Domain.Entities;
+
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
+
+public interface AccountRoleRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/AddressRepository.cs b/src/Application/Common/Persistence/Repositories/AddressRepository.cs
similarity index 54%
rename from src/Application/Common/Interfaces/Persistence/Repositories/AddressRepository.cs
rename to src/Application/Common/Persistence/Repositories/AddressRepository.cs
index 3dfcbf4..0280f38 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/AddressRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/AddressRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface AddressRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/AircraftRepository.cs b/src/Application/Common/Persistence/Repositories/AircraftRepository.cs
similarity index 55%
rename from src/Application/Common/Interfaces/Persistence/Repositories/AircraftRepository.cs
rename to src/Application/Common/Persistence/Repositories/AircraftRepository.cs
index 8ccd4ca..3d82992 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/AircraftRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/AircraftRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface AircraftRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/BaseRepository.cs b/src/Application/Common/Persistence/Repositories/BaseRepository.cs
similarity index 94%
rename from src/Application/Common/Interfaces/Persistence/Repositories/BaseRepository.cs
rename to src/Application/Common/Persistence/Repositories/BaseRepository.cs
index e3b78d5..a89c127 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/BaseRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/BaseRepository.cs
@@ -2,8 +2,7 @@ using System.Linq.Expressions;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface BaseRepository
where TEntity : EntityBase
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/BusRepository.cs b/src/Application/Common/Persistence/Repositories/BusRepository.cs
similarity index 52%
rename from src/Application/Common/Interfaces/Persistence/Repositories/BusRepository.cs
rename to src/Application/Common/Persistence/Repositories/BusRepository.cs
index 18c76dc..d06a5f3 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/BusRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/BusRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface BusRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/CityRepository.cs b/src/Application/Common/Persistence/Repositories/CityRepository.cs
similarity index 53%
rename from src/Application/Common/Interfaces/Persistence/Repositories/CityRepository.cs
rename to src/Application/Common/Persistence/Repositories/CityRepository.cs
index beee75b..4db10a0 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/CityRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/CityRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface CityRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/CompanyRepository.cs b/src/Application/Common/Persistence/Repositories/CompanyRepository.cs
similarity index 70%
rename from src/Application/Common/Interfaces/Persistence/Repositories/CompanyRepository.cs
rename to src/Application/Common/Persistence/Repositories/CompanyRepository.cs
index b65663a..23be434 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/CompanyRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/CompanyRepository.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
+namespace cuqmbr.TravelGuide.Application.Common
.Persistence.Repositories;
public interface CompanyRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/CountryRepository.cs b/src/Application/Common/Persistence/Repositories/CountryRepository.cs
similarity index 54%
rename from src/Application/Common/Interfaces/Persistence/Repositories/CountryRepository.cs
rename to src/Application/Common/Persistence/Repositories/CountryRepository.cs
index 2be573d..1e27047 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/CountryRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/CountryRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface CountryRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/EmployeeRepository.cs b/src/Application/Common/Persistence/Repositories/EmployeeRepository.cs
similarity index 70%
rename from src/Application/Common/Interfaces/Persistence/Repositories/EmployeeRepository.cs
rename to src/Application/Common/Persistence/Repositories/EmployeeRepository.cs
index 012cf93..5941838 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/EmployeeRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/EmployeeRepository.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
+namespace cuqmbr.TravelGuide.Application.Common
.Persistence.Repositories;
public interface EmployeeRepository : BaseRepository { }
diff --git a/src/Application/Common/Persistence/Repositories/RefreshTokenRepository.cs b/src/Application/Common/Persistence/Repositories/RefreshTokenRepository.cs
new file mode 100644
index 0000000..b44ebec
--- /dev/null
+++ b/src/Application/Common/Persistence/Repositories/RefreshTokenRepository.cs
@@ -0,0 +1,5 @@
+using cuqmbr.TravelGuide.Domain.Entities;
+
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
+
+public interface RefreshTokenRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/RegionRepository.cs b/src/Application/Common/Persistence/Repositories/RegionRepository.cs
similarity index 54%
rename from src/Application/Common/Interfaces/Persistence/Repositories/RegionRepository.cs
rename to src/Application/Common/Persistence/Repositories/RegionRepository.cs
index 29ecdfe..29ba027 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/RegionRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/RegionRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface RegionRepository : BaseRepository { }
diff --git a/src/Application/Common/Persistence/Repositories/RoleRepository.cs b/src/Application/Common/Persistence/Repositories/RoleRepository.cs
new file mode 100644
index 0000000..72d3640
--- /dev/null
+++ b/src/Application/Common/Persistence/Repositories/RoleRepository.cs
@@ -0,0 +1,5 @@
+using cuqmbr.TravelGuide.Domain.Entities;
+
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
+
+public interface RoleRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/RouteAddressDetailRepository.cs b/src/Application/Common/Persistence/Repositories/RouteAddressDetailRepository.cs
similarity index 73%
rename from src/Application/Common/Interfaces/Persistence/Repositories/RouteAddressDetailRepository.cs
rename to src/Application/Common/Persistence/Repositories/RouteAddressDetailRepository.cs
index 2bac9d4..b0588ba 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/RouteAddressDetailRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/RouteAddressDetailRepository.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
+namespace cuqmbr.TravelGuide.Application.Common
.Persistence.Repositories;
public interface RouteAddressDetailRepository :
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/RouteAddressRepository.cs b/src/Application/Common/Persistence/Repositories/RouteAddressRepository.cs
similarity index 57%
rename from src/Application/Common/Interfaces/Persistence/Repositories/RouteAddressRepository.cs
rename to src/Application/Common/Persistence/Repositories/RouteAddressRepository.cs
index 4ff5733..8670b9b 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/RouteAddressRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/RouteAddressRepository.cs
@@ -1,7 +1,6 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface RouteAddressRepository :
BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/RouteRepository.cs b/src/Application/Common/Persistence/Repositories/RouteRepository.cs
similarity index 53%
rename from src/Application/Common/Interfaces/Persistence/Repositories/RouteRepository.cs
rename to src/Application/Common/Persistence/Repositories/RouteRepository.cs
index 83249fb..866a0a3 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/RouteRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/RouteRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface RouteRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/TicketGroupRepository.cs b/src/Application/Common/Persistence/Repositories/TicketGroupRepository.cs
similarity index 71%
rename from src/Application/Common/Interfaces/Persistence/Repositories/TicketGroupRepository.cs
rename to src/Application/Common/Persistence/Repositories/TicketGroupRepository.cs
index ead97c3..9dfe535 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/TicketGroupRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/TicketGroupRepository.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
+namespace cuqmbr.TravelGuide.Application.Common
.Persistence.Repositories;
public interface TicketGroupRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/TicketRepository.cs b/src/Application/Common/Persistence/Repositories/TicketRepository.cs
similarity index 70%
rename from src/Application/Common/Interfaces/Persistence/Repositories/TicketRepository.cs
rename to src/Application/Common/Persistence/Repositories/TicketRepository.cs
index 57b96aa..881008c 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/TicketRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/TicketRepository.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
+namespace cuqmbr.TravelGuide.Application.Common
.Persistence.Repositories;
public interface TicketRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/TrainRepository.cs b/src/Application/Common/Persistence/Repositories/TrainRepository.cs
similarity index 53%
rename from src/Application/Common/Interfaces/Persistence/Repositories/TrainRepository.cs
rename to src/Application/Common/Persistence/Repositories/TrainRepository.cs
index 640a507..9358316 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/TrainRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/TrainRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface TrainRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/VehicleEnrollmentEmployeeRepository.cs b/src/Application/Common/Persistence/Repositories/VehicleEnrollmentEmployeeRepository.cs
similarity index 62%
rename from src/Application/Common/Interfaces/Persistence/Repositories/VehicleEnrollmentEmployeeRepository.cs
rename to src/Application/Common/Persistence/Repositories/VehicleEnrollmentEmployeeRepository.cs
index 6c396d2..599dd71 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/VehicleEnrollmentEmployeeRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/VehicleEnrollmentEmployeeRepository.cs
@@ -1,7 +1,6 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface VehicleEnrollmentEmployeeRepository :
BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/VehicleEnrollmentRepository.cs b/src/Application/Common/Persistence/Repositories/VehicleEnrollmentRepository.cs
similarity index 59%
rename from src/Application/Common/Interfaces/Persistence/Repositories/VehicleEnrollmentRepository.cs
rename to src/Application/Common/Persistence/Repositories/VehicleEnrollmentRepository.cs
index 1341b74..763cff0 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/VehicleEnrollmentRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/VehicleEnrollmentRepository.cs
@@ -1,7 +1,6 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface VehicleEnrollmentRepository :
BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/Repositories/VehicleRepository.cs b/src/Application/Common/Persistence/Repositories/VehicleRepository.cs
similarity index 54%
rename from src/Application/Common/Interfaces/Persistence/Repositories/VehicleRepository.cs
rename to src/Application/Common/Persistence/Repositories/VehicleRepository.cs
index db9fde8..7a04b65 100644
--- a/src/Application/Common/Interfaces/Persistence/Repositories/VehicleRepository.cs
+++ b/src/Application/Common/Persistence/Repositories/VehicleRepository.cs
@@ -1,6 +1,5 @@
using cuqmbr.TravelGuide.Domain.Entities;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces
- .Persistence.Repositories;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
public interface VehicleRepository : BaseRepository { }
diff --git a/src/Application/Common/Interfaces/Persistence/UnitOfWork.cs b/src/Application/Common/Persistence/UnitOfWork.cs
similarity index 73%
rename from src/Application/Common/Interfaces/Persistence/UnitOfWork.cs
rename to src/Application/Common/Persistence/UnitOfWork.cs
index 262822a..41bd0aa 100644
--- a/src/Application/Common/Interfaces/Persistence/UnitOfWork.cs
+++ b/src/Application/Common/Persistence/UnitOfWork.cs
@@ -1,9 +1,11 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence.Repositories;
+using cuqmbr.TravelGuide.Application.Common.Persistence.Repositories;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+namespace cuqmbr.TravelGuide.Application.Common.Persistence;
public interface UnitOfWork : IDisposable
{
+ // Application Logic
+
CountryRepository CountryRepository { get; }
RegionRepository RegionRepository { get; }
@@ -38,6 +40,16 @@ public interface UnitOfWork : IDisposable
VehicleEnrollmentEmployeeRepository VehicleEnrollmentEmployeeRepository { get; }
+ // Identity
+
+ AccountRepository AccountRepository { get; }
+
+ RoleRepository RoleRepository { get; }
+
+ AccountRoleRepository AccountRoleRepository { get; }
+
+ RefreshTokenRepository RefreshTokenRepository { get; }
+
int Save();
Task SaveAsync(CancellationToken cancellationToken);
diff --git a/src/Application/Common/Interfaces/Services/CurrencyConverterService.cs b/src/Application/Common/Services/CurrencyConverterService.cs
similarity index 83%
rename from src/Application/Common/Interfaces/Services/CurrencyConverterService.cs
rename to src/Application/Common/Services/CurrencyConverterService.cs
index 4f47c30..e8ae6a0 100644
--- a/src/Application/Common/Interfaces/Services/CurrencyConverterService.cs
+++ b/src/Application/Common/Services/CurrencyConverterService.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Domain.Enums;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+namespace cuqmbr.TravelGuide.Application.Common.Services;
public interface CurrencyConverterService
{
diff --git a/src/Application/Common/Interfaces/Services/LiqPayPaymentService.cs b/src/Application/Common/Services/LiqPayPaymentService.cs
similarity index 82%
rename from src/Application/Common/Interfaces/Services/LiqPayPaymentService.cs
rename to src/Application/Common/Services/LiqPayPaymentService.cs
index 768a1c3..238bb84 100644
--- a/src/Application/Common/Interfaces/Services/LiqPayPaymentService.cs
+++ b/src/Application/Common/Services/LiqPayPaymentService.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Domain.Enums;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+namespace cuqmbr.TravelGuide.Application.Common.Services;
public interface LiqPayPaymentService
{
diff --git a/src/Application/Common/Services/PasswordHasherService.cs b/src/Application/Common/Services/PasswordHasherService.cs
new file mode 100644
index 0000000..a3dc22c
--- /dev/null
+++ b/src/Application/Common/Services/PasswordHasherService.cs
@@ -0,0 +1,10 @@
+namespace cuqmbr.TravelGuide.Application.Common.Services;
+
+public interface PasswordHasherService
+{
+ Task HashAsync(byte[] password, byte[] salt,
+ CancellationToken cancellationToken);
+
+ Task IsValidHashAsync(byte[] hash, byte[] password,
+ byte[] salt, CancellationToken cancellationToken);
+}
diff --git a/src/Application/Common/Interfaces/Services/SessionCurrencyService.cs b/src/Application/Common/Services/SessionCurrencyService.cs
similarity index 64%
rename from src/Application/Common/Interfaces/Services/SessionCurrencyService.cs
rename to src/Application/Common/Services/SessionCurrencyService.cs
index 258a3c0..15e7ce0 100644
--- a/src/Application/Common/Interfaces/Services/SessionCurrencyService.cs
+++ b/src/Application/Common/Services/SessionCurrencyService.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Domain.Enums;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+namespace cuqmbr.TravelGuide.Application.Common.Services;
public interface SessionCurrencyService
{
diff --git a/src/Application/Common/Interfaces/Services/SessionTimeZoneService.cs b/src/Application/Common/Services/SessionTimeZoneService.cs
similarity index 55%
rename from src/Application/Common/Interfaces/Services/SessionTimeZoneService.cs
rename to src/Application/Common/Services/SessionTimeZoneService.cs
index ed60d8b..4b2faaa 100644
--- a/src/Application/Common/Interfaces/Services/SessionTimeZoneService.cs
+++ b/src/Application/Common/Services/SessionTimeZoneService.cs
@@ -1,4 +1,4 @@
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+namespace cuqmbr.TravelGuide.Application.Common.Services;
public interface SessionTimeZoneService
{
diff --git a/src/Application/Common/Services/SessionUserService.cs b/src/Application/Common/Services/SessionUserService.cs
new file mode 100644
index 0000000..7a868ab
--- /dev/null
+++ b/src/Application/Common/Services/SessionUserService.cs
@@ -0,0 +1,22 @@
+using cuqmbr.TravelGuide.Domain.Enums;
+
+namespace cuqmbr.TravelGuide.Application.Common.Services;
+
+public interface SessionUserService
+{
+ public Guid? Guid { get; }
+
+ public string? Username { get; }
+
+ public string? Email { get; }
+
+ public ICollection Roles { get; }
+
+
+ public bool IsAuthenticated => Guid != null;
+
+
+ public string? AccessToken { get; }
+
+ public string? RefreshToken { get; }
+}
diff --git a/src/Application/Common/Interfaces/Services/SessoionCultureService.cs b/src/Application/Common/Services/SessoionCultureService.cs
similarity index 62%
rename from src/Application/Common/Interfaces/Services/SessoionCultureService.cs
rename to src/Application/Common/Services/SessoionCultureService.cs
index 23d7389..32a1aa0 100644
--- a/src/Application/Common/Interfaces/Services/SessoionCultureService.cs
+++ b/src/Application/Common/Services/SessoionCultureService.cs
@@ -1,6 +1,6 @@
using System.Globalization;
-namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+namespace cuqmbr.TravelGuide.Application.Common.Services;
public interface SessionCultureService
{
diff --git a/src/Application/Companies/Commands/AddCompany/AddCompanyCommandAuthorizer.cs b/src/Application/Companies/Commands/AddCompany/AddCompanyCommandAuthorizer.cs
index 7d77ac2..ea238b8 100644
--- a/src/Application/Companies/Commands/AddCompany/AddCompanyCommandAuthorizer.cs
+++ b/src/Application/Companies/Commands/AddCompany/AddCompanyCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Companies.Commands.AddCompany;
diff --git a/src/Application/Companies/Commands/AddCompany/AddCompanyCommandHandler.cs b/src/Application/Companies/Commands/AddCompany/AddCompanyCommandHandler.cs
index 07b4270..2605a86 100644
--- a/src/Application/Companies/Commands/AddCompany/AddCompanyCommandHandler.cs
+++ b/src/Application/Companies/Commands/AddCompany/AddCompanyCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Companies/Commands/AddCompany/AddCompanyCommandValidator.cs b/src/Application/Companies/Commands/AddCompany/AddCompanyCommandValidator.cs
index 209a093..5e522a4 100644
--- a/src/Application/Companies/Commands/AddCompany/AddCompanyCommandValidator.cs
+++ b/src/Application/Companies/Commands/AddCompany/AddCompanyCommandValidator.cs
@@ -1,5 +1,5 @@
using cuqmbr.TravelGuide.Application.Common.FluentValidation;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Companies/Commands/DeleteCompany/DeleteCompanyCommandAuthorizer.cs b/src/Application/Companies/Commands/DeleteCompany/DeleteCompanyCommandAuthorizer.cs
index bfd16e8..446421d 100644
--- a/src/Application/Companies/Commands/DeleteCompany/DeleteCompanyCommandAuthorizer.cs
+++ b/src/Application/Companies/Commands/DeleteCompany/DeleteCompanyCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Companies.Commands.DeleteCompany;
diff --git a/src/Application/Companies/Commands/DeleteCompany/DeleteCompanyCommandHandler.cs b/src/Application/Companies/Commands/DeleteCompany/DeleteCompanyCommandHandler.cs
index 9ceae16..da0a471 100644
--- a/src/Application/Companies/Commands/DeleteCompany/DeleteCompanyCommandHandler.cs
+++ b/src/Application/Companies/Commands/DeleteCompany/DeleteCompanyCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Companies.Commands.DeleteCompany;
diff --git a/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandAuthorizer.cs b/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandAuthorizer.cs
index 5f93add..a3f754b 100644
--- a/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandAuthorizer.cs
+++ b/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Companies.Commands.UpdateCompany;
diff --git a/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandHandler.cs b/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandHandler.cs
index 78e408e..e57cda5 100644
--- a/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandHandler.cs
+++ b/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandValidator.cs b/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandValidator.cs
index a5bb800..c79afb9 100644
--- a/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandValidator.cs
+++ b/src/Application/Companies/Commands/UpdateCompany/UpdateCompanyCommandValidator.cs
@@ -1,5 +1,5 @@
using cuqmbr.TravelGuide.Application.Common.FluentValidation;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryAuthorizer.cs b/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryAuthorizer.cs
index 979329c..3ed1e1a 100644
--- a/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryAuthorizer.cs
+++ b/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Companies.Queries.GetCompaniesPage;
diff --git a/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryHandler.cs b/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryHandler.cs
index 49724c2..3749deb 100644
--- a/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryHandler.cs
+++ b/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryValidator.cs b/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryValidator.cs
index 9f9143c..5fb0088 100644
--- a/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryValidator.cs
+++ b/src/Application/Companies/Queries/GetCompaniesPage/GetCompaniesPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Companies/Queries/GetCompany/GetCompanyQueryAuthorizer.cs b/src/Application/Companies/Queries/GetCompany/GetCompanyQueryAuthorizer.cs
index ce96fe7..f83a0b8 100644
--- a/src/Application/Companies/Queries/GetCompany/GetCompanyQueryAuthorizer.cs
+++ b/src/Application/Companies/Queries/GetCompany/GetCompanyQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Companies.Queries.GetCompany;
diff --git a/src/Application/Companies/Queries/GetCompany/GetCompanyQueryHandler.cs b/src/Application/Companies/Queries/GetCompany/GetCompanyQueryHandler.cs
index 61cc0eb..a625857 100644
--- a/src/Application/Companies/Queries/GetCompany/GetCompanyQueryHandler.cs
+++ b/src/Application/Companies/Queries/GetCompany/GetCompanyQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/ConfigurationOptions.cs b/src/Application/ConfigurationOptions.cs
index e80d048..7a6edea 100644
--- a/src/Application/ConfigurationOptions.cs
+++ b/src/Application/ConfigurationOptions.cs
@@ -7,6 +7,8 @@ public sealed class ConfigurationOptions
public LocalizationConfigurationOptions Localization { get; set; } = new();
public LoggingConfigurationOptions Logging { get; set; } = new();
+
+ public JsonWebTokenConfigurationOptions JsonWebToken { get; set; } = new();
}
public sealed class LocalizationConfigurationOptions
@@ -26,3 +28,16 @@ public sealed class LoggingConfigurationOptions
public bool UseUtcTimestamp { get; set; } = true;
}
+
+public sealed class JsonWebTokenConfigurationOptions
+{
+ public string Issuer { get; set; } = "localhost";
+
+ public string Audience { get; set; } = "localhost";
+
+ public string IssuerSigningKey { get; set; } = "change-me";
+
+ public TimeSpan AccessTokenValidity { get; set; } = TimeSpan.FromMinutes(15);
+
+ public TimeSpan RefreshTokenValidity { get; set; } = TimeSpan.FromDays(3);
+}
diff --git a/src/Application/Countries/Commands/AddCountry/AddCountryCommandAuthorizer.cs b/src/Application/Countries/Commands/AddCountry/AddCountryCommandAuthorizer.cs
index 3ba50fd..930de98 100644
--- a/src/Application/Countries/Commands/AddCountry/AddCountryCommandAuthorizer.cs
+++ b/src/Application/Countries/Commands/AddCountry/AddCountryCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Countries.Commands.AddCountry;
diff --git a/src/Application/Countries/Commands/AddCountry/AddCountryCommandHandler.cs b/src/Application/Countries/Commands/AddCountry/AddCountryCommandHandler.cs
index 91ad72c..fc7399b 100644
--- a/src/Application/Countries/Commands/AddCountry/AddCountryCommandHandler.cs
+++ b/src/Application/Countries/Commands/AddCountry/AddCountryCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Countries/Commands/AddCountry/AddCountryCommandValidator.cs b/src/Application/Countries/Commands/AddCountry/AddCountryCommandValidator.cs
index ec854f3..34fcdae 100644
--- a/src/Application/Countries/Commands/AddCountry/AddCountryCommandValidator.cs
+++ b/src/Application/Countries/Commands/AddCountry/AddCountryCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Countries/Commands/DeleteCountry/DeleteCountryCommandAuthorizer.cs b/src/Application/Countries/Commands/DeleteCountry/DeleteCountryCommandAuthorizer.cs
index 73b8422..1c327b1 100644
--- a/src/Application/Countries/Commands/DeleteCountry/DeleteCountryCommandAuthorizer.cs
+++ b/src/Application/Countries/Commands/DeleteCountry/DeleteCountryCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Countries.Commands.DeleteCountry;
diff --git a/src/Application/Countries/Commands/DeleteCountry/DeleteCountryCommandHandler.cs b/src/Application/Countries/Commands/DeleteCountry/DeleteCountryCommandHandler.cs
index 8f3b55a..39fc2db 100644
--- a/src/Application/Countries/Commands/DeleteCountry/DeleteCountryCommandHandler.cs
+++ b/src/Application/Countries/Commands/DeleteCountry/DeleteCountryCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Countries.Commands.DeleteCountry;
diff --git a/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandAuthorizer.cs b/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandAuthorizer.cs
index dc4994c..dcdfbe7 100644
--- a/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandAuthorizer.cs
+++ b/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Countries.Commands.UpdateCountry;
diff --git a/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandHandler.cs b/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandHandler.cs
index 7d3d822..22fe5fd 100644
--- a/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandHandler.cs
+++ b/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandValidator.cs b/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandValidator.cs
index 6809cb9..52e7d12 100644
--- a/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandValidator.cs
+++ b/src/Application/Countries/Commands/UpdateCountry/UpdateCountryCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryAuthorizer.cs b/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryAuthorizer.cs
index 67796d8..24ac4df 100644
--- a/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryAuthorizer.cs
+++ b/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Countries.Queries.GetCountriesPage;
diff --git a/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryHandler.cs b/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryHandler.cs
index 2ab565d..74b3eeb 100644
--- a/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryHandler.cs
+++ b/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryValidator.cs b/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryValidator.cs
index ceeea99..00ac279 100644
--- a/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryValidator.cs
+++ b/src/Application/Countries/Queries/GetCountriesPage/GetCountriesPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Countries/Queries/GetCountry/GetCountryQueryAuthorizer.cs b/src/Application/Countries/Queries/GetCountry/GetCountryQueryAuthorizer.cs
index 699f958..f158344 100644
--- a/src/Application/Countries/Queries/GetCountry/GetCountryQueryAuthorizer.cs
+++ b/src/Application/Countries/Queries/GetCountry/GetCountryQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Countries.Queries.GetCountry;
diff --git a/src/Application/Countries/Queries/GetCountry/GetCountryQueryHandler.cs b/src/Application/Countries/Queries/GetCountry/GetCountryQueryHandler.cs
index 49851a9..cdd06a2 100644
--- a/src/Application/Countries/Queries/GetCountry/GetCountryQueryHandler.cs
+++ b/src/Application/Countries/Queries/GetCountry/GetCountryQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandAuthorizer.cs b/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandAuthorizer.cs
index 8e2f0d1..1255c27 100644
--- a/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandAuthorizer.cs
+++ b/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Employees.Commands.AddEmployee;
diff --git a/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandHandler.cs b/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandHandler.cs
index 1d528b6..adb5fa0 100644
--- a/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandHandler.cs
+++ b/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandValidator.cs b/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandValidator.cs
index 149bc95..3a9348e 100644
--- a/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandValidator.cs
+++ b/src/Application/Employees/Commands/AddEmployee/AddEmployeeCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Employees/Commands/DeleteEmployee/DeleteEmployeeCommandAuthorizer.cs b/src/Application/Employees/Commands/DeleteEmployee/DeleteEmployeeCommandAuthorizer.cs
index e2f0478..f5b826f 100644
--- a/src/Application/Employees/Commands/DeleteEmployee/DeleteEmployeeCommandAuthorizer.cs
+++ b/src/Application/Employees/Commands/DeleteEmployee/DeleteEmployeeCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Employees.Commands.DeleteEmployee;
diff --git a/src/Application/Employees/Commands/DeleteEmployee/DeleteEmployeeCommandHandler.cs b/src/Application/Employees/Commands/DeleteEmployee/DeleteEmployeeCommandHandler.cs
index 2e7c8c3..539ebcf 100644
--- a/src/Application/Employees/Commands/DeleteEmployee/DeleteEmployeeCommandHandler.cs
+++ b/src/Application/Employees/Commands/DeleteEmployee/DeleteEmployeeCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Employees.Commands.DeleteEmployee;
diff --git a/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandAuthorizer.cs b/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandAuthorizer.cs
index e3ff38e..52bd256 100644
--- a/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandAuthorizer.cs
+++ b/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Employees.Commands.UpdateEmployee;
diff --git a/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandHandler.cs b/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandHandler.cs
index 80d3d26..293fb38 100644
--- a/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandHandler.cs
+++ b/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandValidator.cs b/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandValidator.cs
index e6cf45e..ac4fdb0 100644
--- a/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandValidator.cs
+++ b/src/Application/Employees/Commands/UpdateEmployee/UpdateEmployeeCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Employees/Queries/GetEmployee/GetEmployeeQueryAuthorizer.cs b/src/Application/Employees/Queries/GetEmployee/GetEmployeeQueryAuthorizer.cs
index 6011990..5334ff2 100644
--- a/src/Application/Employees/Queries/GetEmployee/GetEmployeeQueryAuthorizer.cs
+++ b/src/Application/Employees/Queries/GetEmployee/GetEmployeeQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Employees.Queries.GetEmployee;
diff --git a/src/Application/Employees/Queries/GetEmployee/GetEmployeeQueryHandler.cs b/src/Application/Employees/Queries/GetEmployee/GetEmployeeQueryHandler.cs
index 2e3edcb..f8f7517 100644
--- a/src/Application/Employees/Queries/GetEmployee/GetEmployeeQueryHandler.cs
+++ b/src/Application/Employees/Queries/GetEmployee/GetEmployeeQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryAuthorizer.cs b/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryAuthorizer.cs
index 775eeb3..b86a3cb 100644
--- a/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryAuthorizer.cs
+++ b/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Employees.Queries.GetEmployeesPage;
diff --git a/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryHandler.cs b/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryHandler.cs
index 21a5a81..ba18ac0 100644
--- a/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryHandler.cs
+++ b/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryValidator.cs b/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryValidator.cs
index c85edf2..5b3e464 100644
--- a/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryValidator.cs
+++ b/src/Application/Employees/Queries/GetEmployeesPage/GetEmployeesPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Identity/Accounts/AccountDto.cs b/src/Application/Identity/Accounts/AccountDto.cs
new file mode 100644
index 0000000..38dfe57
--- /dev/null
+++ b/src/Application/Identity/Accounts/AccountDto.cs
@@ -0,0 +1,27 @@
+using cuqmbr.TravelGuide.Domain.Entities;
+using cuqmbr.TravelGuide.Application.Common.Mappings;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Accounts;
+
+public sealed class AccountDto : IMapFrom
+{
+ public Guid Uuid { get; set; }
+
+ public string Username { get; set; }
+
+ public string Email { get; set; }
+
+ public ICollection Roles { get; set; }
+
+ public void Mapping(MappingProfile profile)
+ {
+ profile.CreateMap()
+ .ForMember(
+ d => d.Uuid,
+ opt => opt.MapFrom(s => s.Guid))
+ .ForMember(
+ d => d.Roles,
+ opt => opt.MapFrom(s =>
+ s.AccountRoles.Select(ar => ar.Role.Value.Name)));
+ }
+}
diff --git a/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommand.cs b/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommand.cs
new file mode 100644
index 0000000..cf5ea4f
--- /dev/null
+++ b/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommand.cs
@@ -0,0 +1,13 @@
+using cuqmbr.TravelGuide.Domain.Enums;
+using MediatR;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Accounts.Commands.AddAccount;
+
+public record AddAccountCommand : IRequest
+{
+ public string Email { get; set; }
+
+ public string Password { get; set; }
+
+ public ICollection Roles { get; set; }
+}
diff --git a/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandAuthorizer.cs b/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandAuthorizer.cs
new file mode 100644
index 0000000..07ff887
--- /dev/null
+++ b/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandAuthorizer.cs
@@ -0,0 +1,31 @@
+using cuqmbr.TravelGuide.Application.Common.Authorization;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
+using MediatR.Behaviors.Authorization;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Accounts.Commands.AddAccount;
+
+public class AddAccountCommandAuthorizer :
+ AbstractRequestAuthorizer
+{
+ private readonly SessionUserService _sessionAccountService;
+
+ public AddAccountCommandAuthorizer(SessionUserService sessionAccountService)
+ {
+ _sessionAccountService = sessionAccountService;
+ }
+
+ public override void BuildPolicy(AddAccountCommand request)
+ {
+ UseRequirement(new MustBeAuthenticatedRequirement
+ {
+ IsAuthenticated= _sessionAccountService.IsAuthenticated
+ });
+
+ UseRequirement(new MustBeInRolesRequirement
+ {
+ RequiredRoles = [IdentityRole.Administrator],
+ UserRoles = _sessionAccountService.Roles
+ });
+ }
+}
diff --git a/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandHandler.cs b/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandHandler.cs
new file mode 100644
index 0000000..0d54557
--- /dev/null
+++ b/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandHandler.cs
@@ -0,0 +1,77 @@
+using MediatR;
+using AutoMapper;
+using cuqmbr.TravelGuide.Application.Common.Exceptions;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
+using cuqmbr.TravelGuide.Domain.Entities;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Accounts.Commands.AddAccount;
+
+public class AddAccountCommandHandler :
+ IRequestHandler
+{
+ private readonly UnitOfWork _unitOfWork;
+ private readonly IMapper _mapper;
+ private readonly PasswordHasherService _passwordHasherService;
+
+ public AddAccountCommandHandler(
+ UnitOfWork unitOfWork,
+ IMapper mapper,
+ PasswordHasherService passwordHasherService)
+ {
+ _unitOfWork = unitOfWork;
+ _mapper = mapper;
+ _passwordHasherService = passwordHasherService;
+ }
+
+ public async Task Handle(
+ AddAccountCommand request,
+ CancellationToken cancellationToken)
+ {
+ var user = await _unitOfWork.AccountRepository.GetOneAsync(
+ e => e.Email == request.Email,
+ cancellationToken);
+
+ if (user != null)
+ {
+ throw new DuplicateEntityException();
+ }
+
+
+ var roles = (await _unitOfWork.RoleRepository
+ .GetPageAsync(
+ e => request.Roles.Contains(e.Value),
+ 1, request.Roles.Count, cancellationToken))
+ .Items;
+
+ var salt = RandomNumberGenerator.GetBytes(128 / 8);
+ var hash = await _passwordHasherService.HashAsync(
+ Encoding.UTF8.GetBytes(request.Password),
+ salt, cancellationToken);
+
+ var saltBase64 = Convert.ToBase64String(salt);
+ var hashBase64 = Convert.ToBase64String(hash);
+
+ user = new Account()
+ {
+ Email = request.Email,
+ PasswordHash = hashBase64,
+ PasswordSalt = saltBase64,
+ AccountRoles = roles.Select(r => new AccountRole()
+ {
+ RoleId = r.Id
+ })
+ .ToArray()
+ };
+
+ user = await _unitOfWork.AccountRepository.AddOneAsync(
+ user, cancellationToken);
+
+ await _unitOfWork.SaveAsync(cancellationToken);
+ _unitOfWork.Dispose();
+
+ return _mapper.Map(user);
+ }
+}
diff --git a/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandValidator.cs b/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandValidator.cs
new file mode 100644
index 0000000..62586db
--- /dev/null
+++ b/src/Application/Identity/Accounts/Commands/AddAccount/AddAccountCommandValidator.cs
@@ -0,0 +1,36 @@
+using cuqmbr.TravelGuide.Application.Common.FluentValidation;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using FluentValidation;
+using Microsoft.Extensions.Localization;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Accounts.Commands.AddAccount;
+
+public class AddAccountCommandValidator : AbstractValidator
+{
+ public AddAccountCommandValidator(
+ IStringLocalizer localizer,
+ SessionCultureService cultureService)
+ {
+ RuleFor(v => v.Email)
+ .NotEmpty()
+ .WithMessage(localizer["FluentValidation.NotEmpty"])
+ .IsEmail()
+ .WithMessage(localizer["FluentValidation.IsEmail"]);
+
+ RuleFor(v => v.Password)
+ .NotEmpty()
+ .WithMessage(localizer["FluentValidation.NotEmpty"])
+ .MinimumLength(8)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.MinimumLength"],
+ 8))
+ .MaximumLength(64)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.MaximumLength"],
+ 64));
+ }
+}
diff --git a/src/Application/Identity/Accounts/ViewModels/AddAccountViewModel.cs b/src/Application/Identity/Accounts/ViewModels/AddAccountViewModel.cs
new file mode 100644
index 0000000..c8c8bc3
--- /dev/null
+++ b/src/Application/Identity/Accounts/ViewModels/AddAccountViewModel.cs
@@ -0,0 +1,10 @@
+namespace cuqmbr.TravelGuide.Application.Identity.Accounts.ViewModels;
+
+public sealed class AddAccountViewModel
+{
+ public string Email { get; set; }
+
+ public string Password { get; set; }
+
+ public ICollection Roles { get; set; }
+}
diff --git a/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQuery.cs b/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQuery.cs
new file mode 100644
index 0000000..47936af
--- /dev/null
+++ b/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQuery.cs
@@ -0,0 +1,13 @@
+using cuqmbr.TravelGuide.Application.Common.Models;
+using MediatR;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Roles.Queries.GetRolesPage;
+
+public record GetRolesPageQuery : IRequest>
+{
+ public int PageNumber { get; set; } = 1;
+
+ public int PageSize { get; set; } = 10;
+
+ public string Search { get; set; } = String.Empty;
+}
diff --git a/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryAuthorizer.cs b/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryAuthorizer.cs
new file mode 100644
index 0000000..cc167f7
--- /dev/null
+++ b/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryAuthorizer.cs
@@ -0,0 +1,31 @@
+using cuqmbr.TravelGuide.Application.Common.Authorization;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
+using MediatR.Behaviors.Authorization;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Roles.Queries.GetRolesPage;
+
+public class GetRolesPageQueryAuthorizer :
+ AbstractRequestAuthorizer
+{
+ private readonly SessionUserService _sessionUserService;
+
+ public GetRolesPageQueryAuthorizer(SessionUserService sessionUserService)
+ {
+ _sessionUserService = sessionUserService;
+ }
+
+ public override void BuildPolicy(GetRolesPageQuery request)
+ {
+ UseRequirement(new MustBeAuthenticatedRequirement
+ {
+ IsAuthenticated= _sessionUserService.IsAuthenticated
+ });
+
+ UseRequirement(new MustBeInRolesRequirement
+ {
+ RequiredRoles = [IdentityRole.Administrator],
+ UserRoles = _sessionUserService.Roles
+ });
+ }
+}
diff --git a/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryHandler.cs b/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryHandler.cs
new file mode 100644
index 0000000..718ccd0
--- /dev/null
+++ b/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryHandler.cs
@@ -0,0 +1,25 @@
+using MediatR;
+using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Domain.Enums;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Roles.Queries.GetRolesPage;
+
+public class GetRolesPageQueryHandler :
+ IRequestHandler>
+{
+ public async Task> Handle(
+ GetRolesPageQuery request,
+ CancellationToken cancellationToken)
+ {
+ var roleStrings = IdentityRole.Enumerations.Select(e => e.Value.Name);
+
+ var roleCount = roleStrings.Count();
+
+ var filteredRoles = roleStrings
+ .Where(r => r.Contains(request.Search))
+ .ToArray();
+
+ return new PaginatedList(
+ filteredRoles, roleCount, request.PageNumber, request.PageSize);
+ }
+}
diff --git a/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryValidator.cs b/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryValidator.cs
new file mode 100644
index 0000000..cbcd22b
--- /dev/null
+++ b/src/Application/Identity/Roles/Queries/GetRolesPage/GetRolesPageQueryValidator.cs
@@ -0,0 +1,43 @@
+using cuqmbr.TravelGuide.Application.Common.Services;
+using FluentValidation;
+using Microsoft.Extensions.Localization;
+
+namespace cuqmbr.TravelGuide.Application.Identity.Roles.Queries.GetRolesPage;
+
+public class GetRolesPageQueryValidator : AbstractValidator
+{
+ public GetRolesPageQueryValidator(
+ IStringLocalizer localizer,
+ SessionCultureService cultureService)
+ {
+ RuleFor(v => v.PageNumber)
+ .GreaterThanOrEqualTo(1)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.GreaterThanOrEqualTo"],
+ 1));
+
+ RuleFor(v => v.PageSize)
+ .GreaterThanOrEqualTo(1)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.GreaterThanOrEqualTo"],
+ 1))
+ .LessThanOrEqualTo(50)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.LessThanOrEqualTo"],
+ 50));
+
+ RuleFor(v => v.Search)
+ .MaximumLength(64)
+ .WithMessage(
+ String.Format(
+ cultureService.Culture,
+ localizer["FluentValidation.MaximumLength"],
+ 64));
+ }
+}
diff --git a/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandAuthorizer.cs b/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandAuthorizer.cs
index a1ad297..15e36c4 100644
--- a/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandAuthorizer.cs
+++ b/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Payments.LiqPay
diff --git a/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandHandler.cs b/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandHandler.cs
index 94fcde6..d5ac855 100644
--- a/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandHandler.cs
+++ b/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandHandler.cs
@@ -1,8 +1,8 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation.Results;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandValidator.cs b/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandValidator.cs
index 7fbc8eb..fa1f227 100644
--- a/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandValidator.cs
+++ b/src/Application/Payments/LiqPay/TicketGroups/Commands/GetPaymentLink/GetPaymentLinkCommandValidator.cs
@@ -1,5 +1,5 @@
using cuqmbr.TravelGuide.Application.Common.FluentValidation;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Payments/LiqPay/TicketGroups/Commands/ProcessCallback/ProcessCallbackCommandHandler.cs b/src/Application/Payments/LiqPay/TicketGroups/Commands/ProcessCallback/ProcessCallbackCommandHandler.cs
index 1f3d54b..ade9098 100644
--- a/src/Application/Payments/LiqPay/TicketGroups/Commands/ProcessCallback/ProcessCallbackCommandHandler.cs
+++ b/src/Application/Payments/LiqPay/TicketGroups/Commands/ProcessCallback/ProcessCallbackCommandHandler.cs
@@ -1,6 +1,6 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using System.Text;
using Newtonsoft.Json;
diff --git a/src/Application/Payments/LiqPay/TicketGroups/Commands/ProcessCallback/ProcessCallbackCommandValidator.cs b/src/Application/Payments/LiqPay/TicketGroups/Commands/ProcessCallback/ProcessCallbackCommandValidator.cs
index 70faa59..ccec5f5 100644
--- a/src/Application/Payments/LiqPay/TicketGroups/Commands/ProcessCallback/ProcessCallbackCommandValidator.cs
+++ b/src/Application/Payments/LiqPay/TicketGroups/Commands/ProcessCallback/ProcessCallbackCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Regions/Commands/AddRegion/AddRegionCommandAuthorizer.cs b/src/Application/Regions/Commands/AddRegion/AddRegionCommandAuthorizer.cs
index 05be471..7accab4 100644
--- a/src/Application/Regions/Commands/AddRegion/AddRegionCommandAuthorizer.cs
+++ b/src/Application/Regions/Commands/AddRegion/AddRegionCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Regions.Commands.AddRegion;
diff --git a/src/Application/Regions/Commands/AddRegion/AddRegionCommandHandler.cs b/src/Application/Regions/Commands/AddRegion/AddRegionCommandHandler.cs
index 0b5000e..a2acfcc 100644
--- a/src/Application/Regions/Commands/AddRegion/AddRegionCommandHandler.cs
+++ b/src/Application/Regions/Commands/AddRegion/AddRegionCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Regions/Commands/AddRegion/AddRegionCommandValidator.cs b/src/Application/Regions/Commands/AddRegion/AddRegionCommandValidator.cs
index 9d3de32..d94ecf2 100644
--- a/src/Application/Regions/Commands/AddRegion/AddRegionCommandValidator.cs
+++ b/src/Application/Regions/Commands/AddRegion/AddRegionCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Regions/Commands/DeleteRegion/DeleteRegionCommandAuthorizer.cs b/src/Application/Regions/Commands/DeleteRegion/DeleteRegionCommandAuthorizer.cs
index 593eb3b..07f9266 100644
--- a/src/Application/Regions/Commands/DeleteRegion/DeleteRegionCommandAuthorizer.cs
+++ b/src/Application/Regions/Commands/DeleteRegion/DeleteRegionCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Regions.Commands.DeleteRegion;
diff --git a/src/Application/Regions/Commands/DeleteRegion/DeleteRegionCommandHandler.cs b/src/Application/Regions/Commands/DeleteRegion/DeleteRegionCommandHandler.cs
index aba2cf7..2688c20 100644
--- a/src/Application/Regions/Commands/DeleteRegion/DeleteRegionCommandHandler.cs
+++ b/src/Application/Regions/Commands/DeleteRegion/DeleteRegionCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Regions.Commands.DeleteRegion;
diff --git a/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandAuthorizer.cs b/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandAuthorizer.cs
index d36cd2d..2ef62f7 100644
--- a/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandAuthorizer.cs
+++ b/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Regions.Commands.UpdateRegion;
diff --git a/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandHandler.cs b/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandHandler.cs
index 5f8d461..44de767 100644
--- a/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandHandler.cs
+++ b/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandValidator.cs b/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandValidator.cs
index 4366378..dc726ec 100644
--- a/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandValidator.cs
+++ b/src/Application/Regions/Commands/UpdateRegion/UpdateRegionCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Regions/Queries/GetRegion/GetRegionQueryAuthorizer.cs b/src/Application/Regions/Queries/GetRegion/GetRegionQueryAuthorizer.cs
index 55ebab2..f3fd0f3 100644
--- a/src/Application/Regions/Queries/GetRegion/GetRegionQueryAuthorizer.cs
+++ b/src/Application/Regions/Queries/GetRegion/GetRegionQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Regions.Queries.GetRegion;
diff --git a/src/Application/Regions/Queries/GetRegion/GetRegionQueryHandler.cs b/src/Application/Regions/Queries/GetRegion/GetRegionQueryHandler.cs
index c50a2df..d7c71e2 100644
--- a/src/Application/Regions/Queries/GetRegion/GetRegionQueryHandler.cs
+++ b/src/Application/Regions/Queries/GetRegion/GetRegionQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryAuthorizer.cs b/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryAuthorizer.cs
index e742d58..248159e 100644
--- a/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryAuthorizer.cs
+++ b/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Regions.Queries.GetRegionsPage;
diff --git a/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryHandler.cs b/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryHandler.cs
index 42c1143..a14c545 100644
--- a/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryHandler.cs
+++ b/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryValidator.cs b/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryValidator.cs
index b064c3d..8f0ba44 100644
--- a/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryValidator.cs
+++ b/src/Application/Regions/Queries/GetRegionsPage/GetRegionsPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Resources/Localization/en-US.json b/src/Application/Resources/Localization/en-US.json
index dbec72c..832562f 100644
--- a/src/Application/Resources/Localization/en-US.json
+++ b/src/Application/Resources/Localization/en-US.json
@@ -1,10 +1,12 @@
{
"FluentValidation": {
- "MaximumLength": "Must less than {0:G} characters.",
"NotEmpty": "Must not be empty.",
"GreaterThanOrEqualTo": "Must be greater than or equal to {0}.",
"LessThanOrEqualTo": "Must be less than or equal to {0}.",
+ "MinimumLength": "Length must greater than or equal to {0} characters.",
+ "MaximumLength": "Length must less than or equal to {0} characters.",
"MustBeInEnum": "Must be one of the following: {0}.",
+ "IsUsername": "May contain lowercase latin characters (a-z), numbers (0-9), hyphens (-), underscores (_) and dots (.).",
"IsEmail": "Must be a valid email address according to RFC 5321.",
"IsPhoneNumber": "Must be a valid phone number according to ITU-T E.164 with no separator characters.",
"IsUnique": "Elements of the collection must be unique."
@@ -34,7 +36,7 @@
"Title": "Unauthenticated access prevented.",
"Detail": "Request lacks valid authentication credentials for the target resource."
},
- "AithenticationException": {
+ "AuthenticationException": {
"Title": "Authentication failed.",
"Detail": "Check provided credentials validity."
},
diff --git a/src/Application/Routes/Commands/AddRoute/AddRouteCommandAuthorizer.cs b/src/Application/Routes/Commands/AddRoute/AddRouteCommandAuthorizer.cs
index 9040482..559ff04 100644
--- a/src/Application/Routes/Commands/AddRoute/AddRouteCommandAuthorizer.cs
+++ b/src/Application/Routes/Commands/AddRoute/AddRouteCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Routes.Commands.AddRoute;
diff --git a/src/Application/Routes/Commands/AddRoute/AddRouteCommandHandler.cs b/src/Application/Routes/Commands/AddRoute/AddRouteCommandHandler.cs
index df3c7cc..7b83fcf 100644
--- a/src/Application/Routes/Commands/AddRoute/AddRouteCommandHandler.cs
+++ b/src/Application/Routes/Commands/AddRoute/AddRouteCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Routes/Commands/AddRoute/AddRouteCommandValidator.cs b/src/Application/Routes/Commands/AddRoute/AddRouteCommandValidator.cs
index 79fec33..7c33c13 100644
--- a/src/Application/Routes/Commands/AddRoute/AddRouteCommandValidator.cs
+++ b/src/Application/Routes/Commands/AddRoute/AddRouteCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Routes/Commands/DeleteRoute/DeleteRouteCommandAuthorizer.cs b/src/Application/Routes/Commands/DeleteRoute/DeleteRouteCommandAuthorizer.cs
index 8978db7..ec3a774 100644
--- a/src/Application/Routes/Commands/DeleteRoute/DeleteRouteCommandAuthorizer.cs
+++ b/src/Application/Routes/Commands/DeleteRoute/DeleteRouteCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Routes.Commands.DeleteRoute;
diff --git a/src/Application/Routes/Commands/DeleteRoute/DeleteRouteCommandHandler.cs b/src/Application/Routes/Commands/DeleteRoute/DeleteRouteCommandHandler.cs
index d1fde57..bc14a6c 100644
--- a/src/Application/Routes/Commands/DeleteRoute/DeleteRouteCommandHandler.cs
+++ b/src/Application/Routes/Commands/DeleteRoute/DeleteRouteCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Routes.Commands.DeleteRoute;
diff --git a/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandAuthorizer.cs b/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandAuthorizer.cs
index 611b7ae..b4f32e6 100644
--- a/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandAuthorizer.cs
+++ b/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Routes.Commands.UpdateRoute;
diff --git a/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandHandler.cs b/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandHandler.cs
index df48877..f4e1cea 100644
--- a/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandHandler.cs
+++ b/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using FluentValidation.Results;
diff --git a/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandValidator.cs b/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandValidator.cs
index 60b8485..49314d8 100644
--- a/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandValidator.cs
+++ b/src/Application/Routes/Commands/UpdateRoute/UpdateRouteCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Routes/Queries/GetRoute/GetRouteQueryAuthorizer.cs b/src/Application/Routes/Queries/GetRoute/GetRouteQueryAuthorizer.cs
index 7ca5727..16ec495 100644
--- a/src/Application/Routes/Queries/GetRoute/GetRouteQueryAuthorizer.cs
+++ b/src/Application/Routes/Queries/GetRoute/GetRouteQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Routes.Queries.GetRoute;
diff --git a/src/Application/Routes/Queries/GetRoute/GetRouteQueryHandler.cs b/src/Application/Routes/Queries/GetRoute/GetRouteQueryHandler.cs
index 0f8f2db..07e1f16 100644
--- a/src/Application/Routes/Queries/GetRoute/GetRouteQueryHandler.cs
+++ b/src/Application/Routes/Queries/GetRoute/GetRouteQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
using cuqmbr.TravelGuide.Domain.Entities;
diff --git a/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryAuthorizer.cs b/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryAuthorizer.cs
index dc64fa3..57e0d8e 100644
--- a/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryAuthorizer.cs
+++ b/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Routes.Queries.GetRoutesPage;
diff --git a/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryHandler.cs b/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryHandler.cs
index 15e3304..38faa54 100644
--- a/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryHandler.cs
+++ b/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryValidator.cs b/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryValidator.cs
index e38376d..945bebc 100644
--- a/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryValidator.cs
+++ b/src/Application/Routes/Queries/GetRoutesPage/GetRoutesPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandAuthorizer.cs b/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandAuthorizer.cs
index b2c5deb..256e9a3 100644
--- a/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandAuthorizer.cs
+++ b/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.TicketGroups.Commands.AddTicketGroup;
diff --git a/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandHandler.cs b/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandHandler.cs
index 25d4092..d3edfc0 100644
--- a/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandHandler.cs
+++ b/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandHandler.cs
@@ -1,10 +1,10 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using Microsoft.Extensions.Localization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation.Results;
diff --git a/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandValidator.cs b/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandValidator.cs
index 58a8029..03c95c6 100644
--- a/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandValidator.cs
+++ b/src/Application/TicketGroups/Commands/AddTicketGroup/AddTicketGroupCommandValidator.cs
@@ -1,5 +1,5 @@
using cuqmbr.TravelGuide.Application.Common.FluentValidation;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/TicketGroups/Commands/RemoveOldReservedTicketGroups/RemoveOldReservedTicketGroupsCommandHandler.cs b/src/Application/TicketGroups/Commands/RemoveOldReservedTicketGroups/RemoveOldReservedTicketGroupsCommandHandler.cs
index 37373af..e14af8a 100644
--- a/src/Application/TicketGroups/Commands/RemoveOldReservedTicketGroups/RemoveOldReservedTicketGroupsCommandHandler.cs
+++ b/src/Application/TicketGroups/Commands/RemoveOldReservedTicketGroups/RemoveOldReservedTicketGroupsCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Enums;
namespace cuqmbr.TravelGuide.Application.TicketGroups
diff --git a/src/Application/Trains/Commands/AddTrain/AddTrainCommandAuthorizer.cs b/src/Application/Trains/Commands/AddTrain/AddTrainCommandAuthorizer.cs
index 36fdbf4..256c7ea 100644
--- a/src/Application/Trains/Commands/AddTrain/AddTrainCommandAuthorizer.cs
+++ b/src/Application/Trains/Commands/AddTrain/AddTrainCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Trains.Commands.AddTrain;
diff --git a/src/Application/Trains/Commands/AddTrain/AddTrainCommandHandler.cs b/src/Application/Trains/Commands/AddTrain/AddTrainCommandHandler.cs
index 4644d93..b420c50 100644
--- a/src/Application/Trains/Commands/AddTrain/AddTrainCommandHandler.cs
+++ b/src/Application/Trains/Commands/AddTrain/AddTrainCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Trains/Commands/AddTrain/AddTrainCommandValidator.cs b/src/Application/Trains/Commands/AddTrain/AddTrainCommandValidator.cs
index 092bbc9..52e38e8 100644
--- a/src/Application/Trains/Commands/AddTrain/AddTrainCommandValidator.cs
+++ b/src/Application/Trains/Commands/AddTrain/AddTrainCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Trains/Commands/DeleteTrain/DeleteTrainCommandAuthorizer.cs b/src/Application/Trains/Commands/DeleteTrain/DeleteTrainCommandAuthorizer.cs
index df31b90..9e888b6 100644
--- a/src/Application/Trains/Commands/DeleteTrain/DeleteTrainCommandAuthorizer.cs
+++ b/src/Application/Trains/Commands/DeleteTrain/DeleteTrainCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Trains.Commands.DeleteTrain;
diff --git a/src/Application/Trains/Commands/DeleteTrain/DeleteTrainCommandHandler.cs b/src/Application/Trains/Commands/DeleteTrain/DeleteTrainCommandHandler.cs
index 94d3ab0..b3cc70b 100644
--- a/src/Application/Trains/Commands/DeleteTrain/DeleteTrainCommandHandler.cs
+++ b/src/Application/Trains/Commands/DeleteTrain/DeleteTrainCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.Trains.Commands.DeleteTrain;
diff --git a/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandAuthorizer.cs b/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandAuthorizer.cs
index c4dd607..6a5f59c 100644
--- a/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandAuthorizer.cs
+++ b/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Trains.Commands.UpdateTrain;
diff --git a/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandHandler.cs b/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandHandler.cs
index e7be03f..0607955 100644
--- a/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandHandler.cs
+++ b/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandValidator.cs b/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandValidator.cs
index b23fb12..6a2c65e 100644
--- a/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandValidator.cs
+++ b/src/Application/Trains/Commands/UpdateTrain/UpdateTrainCommandValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/Trains/Queries/GetTrain/GetTrainQueryAuthorizer.cs b/src/Application/Trains/Queries/GetTrain/GetTrainQueryAuthorizer.cs
index 7416f04..dc417e7 100644
--- a/src/Application/Trains/Queries/GetTrain/GetTrainQueryAuthorizer.cs
+++ b/src/Application/Trains/Queries/GetTrain/GetTrainQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Trains.Queries.GetTrain;
diff --git a/src/Application/Trains/Queries/GetTrain/GetTrainQueryHandler.cs b/src/Application/Trains/Queries/GetTrain/GetTrainQueryHandler.cs
index afe796b..fe3788e 100644
--- a/src/Application/Trains/Queries/GetTrain/GetTrainQueryHandler.cs
+++ b/src/Application/Trains/Queries/GetTrain/GetTrainQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
diff --git a/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryAuthorizer.cs b/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryAuthorizer.cs
index 2a68aaa..5ce63f8 100644
--- a/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryAuthorizer.cs
+++ b/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.Trains.Queries.GetTrainsPage;
diff --git a/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryHandler.cs b/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryHandler.cs
index 49a0c7d..39892ae 100644
--- a/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryHandler.cs
+++ b/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryValidator.cs b/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryValidator.cs
index a4d9410..087a2b1 100644
--- a/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryValidator.cs
+++ b/src/Application/Trains/Queries/GetTrainsPage/GetTrainsPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryAuthorizer.cs b/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryAuthorizer.cs
index 19ba695..fbc4307 100644
--- a/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryAuthorizer.cs
+++ b/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application
diff --git a/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryHandler.cs b/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryHandler.cs
index f25ba6c..ee286ee 100644
--- a/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryHandler.cs
+++ b/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryHandler.cs
@@ -1,10 +1,10 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using QuikGraph;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using cuqmbr.TravelGuide.Application.Common.Extensions;
diff --git a/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryValidator.cs b/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryValidator.cs
index e12f958..9ed2b6f 100644
--- a/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryValidator.cs
+++ b/src/Application/VehicleEnrollmentSearch/Queries/SearchAll/SearchAllQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryAuthorizer.cs b/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryAuthorizer.cs
index 97eda14..055a5d4 100644
--- a/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryAuthorizer.cs
+++ b/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application
diff --git a/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryHandler.cs b/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryHandler.cs
index afbcc45..17318b5 100644
--- a/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryHandler.cs
+++ b/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryHandler.cs
@@ -1,11 +1,11 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using QuikGraph;
using QuikGraph.Algorithms;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
namespace cuqmbr.TravelGuide.Application
diff --git a/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryValidator.cs b/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryValidator.cs
index 19bb4c4..674e636 100644
--- a/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryValidator.cs
+++ b/src/Application/VehicleEnrollmentSearch/Queries/SearchShortest/SearchShortestQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandAuthorizer.cs b/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandAuthorizer.cs
index dbaeae9..38f64d6 100644
--- a/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandAuthorizer.cs
+++ b/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.VehicleEnrollments
diff --git a/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandHandler.cs b/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandHandler.cs
index b5d8d9c..dc82b55 100644
--- a/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandHandler.cs
+++ b/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Domain.Entities;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
diff --git a/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandValidator.cs b/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandValidator.cs
index 1df07c1..415a15d 100644
--- a/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandValidator.cs
+++ b/src/Application/VehicleEnrollments/Commands/AddVehicleEnrollment/AddVehicleEnrollmentCommandValidator.cs
@@ -1,5 +1,5 @@
using cuqmbr.TravelGuide.Application.Common.FluentValidation;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/VehicleEnrollments/Commands/DeleteVehicleEnrollment/DeleteVehicleEnrollmentCommandAuthorizer.cs b/src/Application/VehicleEnrollments/Commands/DeleteVehicleEnrollment/DeleteVehicleEnrollmentCommandAuthorizer.cs
index ecc544b..4f9c61f 100644
--- a/src/Application/VehicleEnrollments/Commands/DeleteVehicleEnrollment/DeleteVehicleEnrollmentCommandAuthorizer.cs
+++ b/src/Application/VehicleEnrollments/Commands/DeleteVehicleEnrollment/DeleteVehicleEnrollmentCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.VehicleEnrollments.Commands.DeleteVehicleEnrollment;
diff --git a/src/Application/VehicleEnrollments/Commands/DeleteVehicleEnrollment/DeleteVehicleEnrollmentCommandHandler.cs b/src/Application/VehicleEnrollments/Commands/DeleteVehicleEnrollment/DeleteVehicleEnrollmentCommandHandler.cs
index 0dbb95b..b743321 100644
--- a/src/Application/VehicleEnrollments/Commands/DeleteVehicleEnrollment/DeleteVehicleEnrollmentCommandHandler.cs
+++ b/src/Application/VehicleEnrollments/Commands/DeleteVehicleEnrollment/DeleteVehicleEnrollmentCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
namespace cuqmbr.TravelGuide.Application.VehicleEnrollments.Commands.DeleteVehicleEnrollment;
diff --git a/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandAuthorizer.cs b/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandAuthorizer.cs
index 9831597..ad1f9d1 100644
--- a/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandAuthorizer.cs
+++ b/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.VehicleEnrollments
diff --git a/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandHandler.cs b/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandHandler.cs
index fb3aed7..0251fef 100644
--- a/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandHandler.cs
+++ b/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandHandler.cs
@@ -1,5 +1,5 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using FluentValidation.Results;
diff --git a/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandValidator.cs b/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandValidator.cs
index 2530e8c..9e33153 100644
--- a/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandValidator.cs
+++ b/src/Application/VehicleEnrollments/Commands/UpdateVehicleEnrollment/UpdateVehicleEnrollmentCommandValidator.cs
@@ -1,5 +1,5 @@
using cuqmbr.TravelGuide.Application.Common.FluentValidation;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollment/GetVehicleEnrollmentQueryAuthorizer.cs b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollment/GetVehicleEnrollmentQueryAuthorizer.cs
index 58fe68f..a026fff 100644
--- a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollment/GetVehicleEnrollmentQueryAuthorizer.cs
+++ b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollment/GetVehicleEnrollmentQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.VehicleEnrollments
diff --git a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollment/GetVehicleEnrollmentQueryHandler.cs b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollment/GetVehicleEnrollmentQueryHandler.cs
index 3b1ad69..f41760e 100644
--- a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollment/GetVehicleEnrollmentQueryHandler.cs
+++ b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollment/GetVehicleEnrollmentQueryHandler.cs
@@ -1,8 +1,8 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Application.Common.Exceptions;
using AutoMapper;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
namespace cuqmbr.TravelGuide.Application.VehicleEnrollments
diff --git a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryAuthorizer.cs b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryAuthorizer.cs
index fc83c92..4d69da0 100644
--- a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryAuthorizer.cs
+++ b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryAuthorizer.cs
@@ -1,6 +1,6 @@
using cuqmbr.TravelGuide.Application.Common.Authorization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
using MediatR.Behaviors.Authorization;
namespace cuqmbr.TravelGuide.Application.VehicleEnrollments.Queries.GetVehicleEnrollmentsPage;
diff --git a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryHandler.cs b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryHandler.cs
index 70cfc40..af32246 100644
--- a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryHandler.cs
+++ b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryHandler.cs
@@ -1,9 +1,9 @@
using MediatR;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using AutoMapper;
using cuqmbr.TravelGuide.Application.Common.Models;
using cuqmbr.TravelGuide.Application.Common.Extensions;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
namespace cuqmbr.TravelGuide.Application.VehicleEnrollments
diff --git a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryValidator.cs b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryValidator.cs
index 5e0ba41..2d1d71b 100644
--- a/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryValidator.cs
+++ b/src/Application/VehicleEnrollments/Queries/GetVehicleEnrollmentsPage/GetVehicleEnrollmentsPageQueryValidator.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using FluentValidation;
using Microsoft.Extensions.Localization;
diff --git a/src/Application/packages.lock.json b/src/Application/packages.lock.json
index 14b60f0..43c1312 100644
--- a/src/Application/packages.lock.json
+++ b/src/Application/packages.lock.json
@@ -48,6 +48,15 @@
"MediatR.Contracts": "2.0.1"
}
},
+ "Microsoft.AspNetCore.Authentication.JwtBearer": {
+ "type": "Direct",
+ "requested": "[9.0.5, )",
+ "resolved": "9.0.5",
+ "contentHash": "8J04KPX5NCo6j5AjY/rgeLTceMBJ8Sq4k+YNxN/7hCrbCH1iwHVw7VGGvlCscj615ewMX3jYDmxxLdutbSPOcA==",
+ "dependencies": {
+ "Microsoft.IdentityModel.Protocols.OpenIdConnect": "8.0.1"
+ }
+ },
"Microsoft.Extensions.Logging": {
"type": "Direct",
"requested": "[9.0.4, )",
@@ -59,6 +68,25 @@
"Microsoft.Extensions.Options": "9.0.4"
}
},
+ "Microsoft.IdentityModel.JsonWebTokens": {
+ "type": "Direct",
+ "requested": "[8.11.0, )",
+ "resolved": "8.11.0",
+ "contentHash": "rLvApg2vqs/Kz5kVHwHUMAe3owInYrsPX8QP8CQktubX9R63P+J47nR/IOS4n6ddJCvGInUGRBKqcBGJtuA4Rw==",
+ "dependencies": {
+ "Microsoft.IdentityModel.Tokens": "8.11.0"
+ }
+ },
+ "Microsoft.IdentityModel.Tokens": {
+ "type": "Direct",
+ "requested": "[8.11.0, )",
+ "resolved": "8.11.0",
+ "contentHash": "E0iKSD9vv9X+tbHGriMTLkSNK/OOjxOPuf1dt9q32d25Ig+OZaidUqDoUTSS3mWTvPw+x5oXrCTHtDatbzRzTQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Logging.Abstractions": "8.0.0",
+ "Microsoft.IdentityModel.Logging": "8.11.0"
+ }
+ },
"Newtonsoft.Json": {
"type": "Direct",
"requested": "[13.0.3, )",
@@ -182,6 +210,45 @@
"resolved": "9.0.4",
"contentHash": "SPFyMjyku1nqTFFJ928JAMd0QnRe4xjE7KeKnZMWXf3xk+6e0WiOZAluYtLdbJUXtsl2cCRSi8cBquJ408k8RA=="
},
+ "Microsoft.IdentityModel.Abstractions": {
+ "type": "Transitive",
+ "resolved": "8.11.0",
+ "contentHash": "X92UuBmvHYtsVrD+R+senFn6wOtSVtliSZNTZI8oHD+WqhYLmLNlHH6avYcbXqEznozxshSYzD/DVAuz54jjtg=="
+ },
+ "Microsoft.IdentityModel.Logging": {
+ "type": "Transitive",
+ "resolved": "8.11.0",
+ "contentHash": "/JNOMdYOQ4Tgbdwu9GbEcRJEpzakizuECCE8dCgY5lKXyqZUdAKXyeq4zITgS81eZYThqjhQZUYaJxOPofbmrg==",
+ "dependencies": {
+ "Microsoft.IdentityModel.Abstractions": "8.11.0"
+ }
+ },
+ "Microsoft.IdentityModel.Protocols": {
+ "type": "Transitive",
+ "resolved": "8.0.1",
+ "contentHash": "uA2vpKqU3I2mBBEaeJAWPTjT9v1TZrGWKdgK6G5qJd03CLx83kdiqO9cmiK8/n1erkHzFBwU/RphP83aAe3i3g==",
+ "dependencies": {
+ "Microsoft.IdentityModel.Tokens": "8.0.1"
+ }
+ },
+ "Microsoft.IdentityModel.Protocols.OpenIdConnect": {
+ "type": "Transitive",
+ "resolved": "8.0.1",
+ "contentHash": "AQDbfpL+yzuuGhO/mQhKNsp44pm5Jv8/BI4KiFXR7beVGZoSH35zMV3PrmcfvSTsyI6qrcR898NzUauD6SRigg==",
+ "dependencies": {
+ "Microsoft.IdentityModel.Protocols": "8.0.1",
+ "System.IdentityModel.Tokens.Jwt": "8.0.1"
+ }
+ },
+ "System.IdentityModel.Tokens.Jwt": {
+ "type": "Transitive",
+ "resolved": "8.0.1",
+ "contentHash": "GJw3bYkWpOgvN3tJo5X4lYUeIFA2HD293FPUhKmp7qxS+g5ywAb34Dnd3cDAFLkcMohy5XTpoaZ4uAHuw0uSPQ==",
+ "dependencies": {
+ "Microsoft.IdentityModel.JsonWebTokens": "8.0.1",
+ "Microsoft.IdentityModel.Tokens": "8.0.1"
+ }
+ },
"domain": {
"type": "Project"
}
diff --git a/src/Configuration/Application/Configuration.cs b/src/Configuration/Application/Configuration.cs
index cfbd70c..4f078cb 100644
--- a/src/Configuration/Application/Configuration.cs
+++ b/src/Configuration/Application/Configuration.cs
@@ -10,6 +10,8 @@ using MediatR.Behaviors.Authorization.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using cuqmbr.TravelGuide.Application.Common.Authorization;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.IdentityModel.Tokens;
namespace cuqmbr.TravelGuide.Configuration.Application;
@@ -18,15 +20,16 @@ public static class Configuration
public static IServiceCollection ConfigureApplication(
this IServiceCollection services)
{
- var configurationOptions = services.BuildServiceProvider().GetService<
+ var configuration = services.BuildServiceProvider().GetService<
IOptions>()
.Value;
return services
- .AddLocalization(configurationOptions.Localization)
+ .AddLocalization(configuration.Localization)
.AddFluentValidation()
.AddAutoMapper()
- .AddMediatR();
+ .AddMediatR()
+ .AddAuthentication(configuration.JsonWebToken);
}
private static IServiceCollection AddFluentValidation(
@@ -91,4 +94,42 @@ public static class Configuration
.Assembly);
});
}
+
+ private static IServiceCollection AddAuthentication(
+ this IServiceCollection services,
+ JsonWebTokenConfigurationOptions configuration)
+ {
+ services
+ .AddAuthentication(options =>
+ {
+ options.DefaultAuthenticateScheme =
+ JwtBearerDefaults.AuthenticationScheme;
+ options.DefaultChallengeScheme =
+ JwtBearerDefaults.AuthenticationScheme;
+ options.DefaultScheme =
+ JwtBearerDefaults.AuthenticationScheme;
+ })
+ .AddJwtBearer(options =>
+ {
+ options.IncludeErrorDetails = true;
+ options.SaveToken = true;
+ options.RequireHttpsMetadata = false;
+ options.TokenValidationParameters =
+ new TokenValidationParameters()
+ {
+ ValidateIssuer = false,
+ ValidateAudience = false,
+ ValidateLifetime = true,
+ ValidateIssuerSigningKey = true,
+ ValidAudience = configuration.Audience,
+ ValidIssuer = configuration.Issuer,
+ ClockSkew = TimeSpan.Zero,
+ IssuerSigningKey = new SymmetricSecurityKey(
+ Encoding.UTF8.GetBytes(
+ configuration.IssuerSigningKey))
+ };
+ });
+
+ return services;
+ }
}
diff --git a/src/Configuration/Configuration/Configuration.cs b/src/Configuration/Configuration/Configuration.cs
index 5a8d825..923b7f8 100644
--- a/src/Configuration/Configuration/Configuration.cs
+++ b/src/Configuration/Configuration/Configuration.cs
@@ -6,8 +6,6 @@ using ApplicationConfigurationOptions =
cuqmbr.TravelGuide.Application.ConfigurationOptions;
using InfrastructureConfigurationOptions =
cuqmbr.TravelGuide.Infrastructure.ConfigurationOptions;
-using IdentityConfigurationOptions =
- cuqmbr.TravelGuide.Identity.ConfigurationOptions;
namespace cuqmbr.TravelGuide.Configuration.Configuration;
@@ -39,10 +37,6 @@ public static class Configuration
configuration.GetSection(
InfrastructureConfigurationOptions.SectionName));
- services.AddOptions().Bind(
- configuration.GetSection(
- IdentityConfigurationOptions.SectionName));
-
return services;
}
}
diff --git a/src/Configuration/Identity/Configuration.cs b/src/Configuration/Identity/Configuration.cs
deleted file mode 100644
index 0aba448..0000000
--- a/src/Configuration/Identity/Configuration.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using cuqmbr.TravelGuide.Identity.Persistence.PostgreSql;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Options;
-using IdentityUser = cuqmbr.TravelGuide.Identity.Models.IdentityUser;
-using IdentityRole = cuqmbr.TravelGuide.Identity.Models.IdentityRole;
-using Microsoft.EntityFrameworkCore;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Identity.Services;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.IdentityModel.Tokens;
-using System.Text;
-using cuqmbr.TravelGuide.Identity.Exceptions;
-using Microsoft.EntityFrameworkCore.Diagnostics;
-
-namespace cuqmbr.TravelGuide.Configuration.Identity;
-
-public static class Configuration
-{
- public static IServiceCollection ConfigureIdentity(
- this IServiceCollection services)
- {
- using var configurationServiceProvider = services.BuildServiceProvider();
- var configuration = configurationServiceProvider.GetService<
- IOptions>()
- .Value;
-
- // TODO: Make enum from available datastore types
-
- if (configuration.Datastore.Type.ToLower().Equals("postgresql"))
- {
- services.AddDbContext(options =>
- {
- options.UseNpgsql(
- configuration.Datastore.ConnectionString,
- options =>
- {
- options.MigrationsHistoryTable(
- "ef_migrations_history",
- configuration.Datastore.PartitionName);
- });
- options.ConfigureWarnings(w => w.Ignore(
- RelationalEventId.PendingModelChangesWarning));
- });
-
- services
- .AddIdentity()
- .AddEntityFrameworkStores()
- .AddDefaultTokenProviders();
-
- if (configuration.Datastore.Migrate)
- {
- using var dbContextServiceProvider = services.BuildServiceProvider();
- PostgreSqlInitializer.Initialize(dbContextServiceProvider);
- }
- }
- else
- {
- throw new UnSupportedDatastoreException(
- $"{configuration.Datastore.Type} datastore is not supported.");
- }
-
- services
- .AddScoped();
-
- services
- .AddAuthentication(options =>
- {
- options.DefaultAuthenticateScheme =
- JwtBearerDefaults.AuthenticationScheme;
- options.DefaultChallengeScheme =
- JwtBearerDefaults.AuthenticationScheme;
- options.DefaultScheme =
- JwtBearerDefaults.AuthenticationScheme;
- })
- .AddJwtBearer(options =>
- {
- options.IncludeErrorDetails = true;
- options.SaveToken = true;
- options.RequireHttpsMetadata = false;
- options.TokenValidationParameters =
- new TokenValidationParameters()
- {
- ValidateIssuer = false,
- ValidateAudience = false,
- ValidateLifetime = true,
- ValidateIssuerSigningKey = true,
- ValidAudience = configuration.JsonWebToken.Audience,
- ValidIssuer = configuration.JsonWebToken.Issuer,
- ClockSkew = TimeSpan.Zero,
- IssuerSigningKey = new SymmetricSecurityKey(
- Encoding.UTF8.GetBytes(
- configuration.JsonWebToken.IssuerSigningKey))
- };
- });
-
- return services;
- }
-}
diff --git a/src/Configuration/Infrastructure/Configuration.cs b/src/Configuration/Infrastructure/Configuration.cs
index 3df6bb0..1c35fe6 100644
--- a/src/Configuration/Infrastructure/Configuration.cs
+++ b/src/Configuration/Infrastructure/Configuration.cs
@@ -1,5 +1,5 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
using cuqmbr.TravelGuide.Infrastructure.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using Microsoft.Extensions.DependencyInjection;
namespace cuqmbr.TravelGuide.Configuration.Infrastructure;
@@ -13,11 +13,14 @@ public static class Configuration
.AddHttpClient();
services
+ .AddScoped<
+ PasswordHasherService,
+ Pbkdf2PasswordHasherService>()
.AddScoped<
CurrencyConverterService,
ExchangeApiCurrencyConverterService>()
.AddScoped<
- cuqmbr.TravelGuide.Application.Common.Interfaces.Services.LiqPayPaymentService,
+ cuqmbr.TravelGuide.Application.Common.Services.LiqPayPaymentService,
cuqmbr.TravelGuide.Infrastructure.Services.LiqPayPaymentService>();
return services;
diff --git a/src/Configuration/Persistence/Configuration.cs b/src/Configuration/Persistence/Configuration.cs
index a506520..4ab16fb 100644
--- a/src/Configuration/Persistence/Configuration.cs
+++ b/src/Configuration/Persistence/Configuration.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
using cuqmbr.TravelGuide.Persistence;
using cuqmbr.TravelGuide.Persistence.Exceptions;
using Microsoft.EntityFrameworkCore;
@@ -45,10 +45,10 @@ public static class Configuration
if (configuration.Migrate)
{
- using var dbContextServiceProvider =
+ using var serviceProvider =
services.BuildServiceProvider();
var dbContext =
- dbContextServiceProvider.GetService();
+ serviceProvider.GetService();
PostgreSqlDbInitializer.Initialize(dbContext);
}
}
@@ -79,8 +79,7 @@ public static class Configuration
if (configuration.Seed)
{
using var serviceProvider = services.BuildServiceProvider();
- var unitOfWork = serviceProvider.GetService();
- DbSeeder.Seed(unitOfWork);
+ DbSeeder.Seed(serviceProvider);
}
return services;
diff --git a/src/Configuration/packages.lock.json b/src/Configuration/packages.lock.json
index f253c37..bba215c 100644
--- a/src/Configuration/packages.lock.json
+++ b/src/Configuration/packages.lock.json
@@ -236,8 +236,8 @@
},
"Microsoft.AspNetCore.Authentication.JwtBearer": {
"type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "0HgfWPfnjlzWFbW4pw6FYNuIMV8obVU+MUkiZ33g4UOpvZcmdWzdayfheKPZ5+EUly8SvfgW0dJwwIrW4IVLZQ==",
+ "resolved": "9.0.5",
+ "contentHash": "8J04KPX5NCo6j5AjY/rgeLTceMBJ8Sq4k+YNxN/7hCrbCH1iwHVw7VGGvlCscj615ewMX3jYDmxxLdutbSPOcA==",
"dependencies": {
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "8.0.1"
}
@@ -268,15 +268,15 @@
},
"Microsoft.AspNetCore.Cryptography.Internal": {
"type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "E4pHyEb2Ul5a6bIwraGtw9TN39a/C2asyVPEJoyItc0reV4Y26FsPcEdcXyKjBbP4kSz9iU1Cz4Yhx/aOFPpqA=="
+ "resolved": "2.3.0",
+ "contentHash": "/qy5r0CD40OccajzDmX3gBfqqxpAJkcXoqlVz0YR70x3gTRq/VuseDU/lZ5eh8vM+KCdmPFAtyGcRWxTyXxuYg=="
},
"Microsoft.AspNetCore.Cryptography.KeyDerivation": {
"type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "5v9Kj2arRrCftLKW80Hfj31HkNnjcKyw57lQhF84drvGxJlCR63J0zMM1sMM+Hc+KCQjuoDmHtjwN0uOT+X3ag==",
+ "resolved": "2.3.0",
+ "contentHash": "S7pph0JuBkgNqtyiIdLtQ5icZxmpX502zxxvHuMtM5W7IR3CKl1r/Cup+i6+E6B7IF3BeZYF4O3RbcA108syig==",
"dependencies": {
- "Microsoft.AspNetCore.Cryptography.Internal": "9.0.4"
+ "Microsoft.AspNetCore.Cryptography.Internal": "2.3.0"
}
},
"Microsoft.AspNetCore.DataProtection": {
@@ -359,15 +359,6 @@
"Microsoft.Extensions.Primitives": "8.0.0"
}
},
- "Microsoft.AspNetCore.Identity.EntityFrameworkCore": {
- "type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "IC3X6Db6H0cXdE2zGtyk/jmSwXhHbJZaiNpg7TNFV/Biu/NgO6l/GuwgE0D1U6U9pca00WsqxESkNov+WA77CA==",
- "dependencies": {
- "Microsoft.EntityFrameworkCore.Relational": "9.0.4",
- "Microsoft.Extensions.Identity.Stores": "9.0.4"
- }
- },
"Microsoft.AspNetCore.Metadata": {
"type": "Transitive",
"resolved": "9.0.0",
@@ -564,22 +555,13 @@
},
"Microsoft.Extensions.Identity.Core": {
"type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "KKfCsoIHFGZmmCEjZBPuvDW0pCjboMru/Z3vbEyC/OIwUVeKrdPugFyjc81i7rNSjcPcDxVvGl/Ks8HLelKocg==",
+ "resolved": "2.3.0",
+ "contentHash": "yR0eFnUbAM2k+q5QsX0NKinfShIe1B/aiHXEywiNT5Cs2MvEhxQIbIn5rWXnEAfmwW+i+t5D8odPSEHz/taIyQ==",
"dependencies": {
- "Microsoft.AspNetCore.Cryptography.KeyDerivation": "9.0.4",
- "Microsoft.Extensions.Logging": "9.0.4",
- "Microsoft.Extensions.Options": "9.0.4"
- }
- },
- "Microsoft.Extensions.Identity.Stores": {
- "type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "0F6lSngwyXzrv+qtX46nhHYBOlPxEzj0qyCCef1kvlyEYhbj8kBL13FuDk4nEPkzk1yVjZgsnXBG19+TrNdakQ==",
- "dependencies": {
- "Microsoft.Extensions.Caching.Abstractions": "9.0.4",
- "Microsoft.Extensions.Identity.Core": "9.0.4",
- "Microsoft.Extensions.Logging": "9.0.4"
+ "Microsoft.AspNetCore.Cryptography.KeyDerivation": "2.3.0",
+ "Microsoft.Extensions.Logging": "8.0.1",
+ "Microsoft.Extensions.Options": "8.0.2",
+ "System.ComponentModel.Annotations": "5.0.0"
}
},
"Microsoft.Extensions.Localization": {
@@ -651,23 +633,23 @@
},
"Microsoft.IdentityModel.Abstractions": {
"type": "Transitive",
- "resolved": "8.8.0",
- "contentHash": "0lKw+f3vkmV9t3PLe6sY3xPrYrHYiMRFxuOse5CMkKPxhQYiabpfJsuk6wX2RrVQ86Dn+t/8poHpH0nbp6sFvA=="
+ "resolved": "8.11.0",
+ "contentHash": "X92UuBmvHYtsVrD+R+senFn6wOtSVtliSZNTZI8oHD+WqhYLmLNlHH6avYcbXqEznozxshSYzD/DVAuz54jjtg=="
},
"Microsoft.IdentityModel.JsonWebTokens": {
"type": "Transitive",
- "resolved": "8.8.0",
- "contentHash": "lepOkZZTMfJCPSnWITXxV+4Wxb54g+9oIybs9YovlOzZWuR1i2DOpzaDgSe+piDJaGtnSrcUlcB9fZ5Swur7Uw==",
+ "resolved": "8.11.0",
+ "contentHash": "rLvApg2vqs/Kz5kVHwHUMAe3owInYrsPX8QP8CQktubX9R63P+J47nR/IOS4n6ddJCvGInUGRBKqcBGJtuA4Rw==",
"dependencies": {
- "Microsoft.IdentityModel.Tokens": "8.8.0"
+ "Microsoft.IdentityModel.Tokens": "8.11.0"
}
},
"Microsoft.IdentityModel.Logging": {
"type": "Transitive",
- "resolved": "8.8.0",
- "contentHash": "sUyoxzg/WBZobbFLJK8loT9IILKtS9ePmWu5B11ogQqhSHppE6SRZKw0fhI6Fd16X6ey52cbbWc2rvMBC98EQA==",
+ "resolved": "8.11.0",
+ "contentHash": "/JNOMdYOQ4Tgbdwu9GbEcRJEpzakizuECCE8dCgY5lKXyqZUdAKXyeq4zITgS81eZYThqjhQZUYaJxOPofbmrg==",
"dependencies": {
- "Microsoft.IdentityModel.Abstractions": "8.8.0"
+ "Microsoft.IdentityModel.Abstractions": "8.11.0"
}
},
"Microsoft.IdentityModel.Protocols": {
@@ -689,11 +671,11 @@
},
"Microsoft.IdentityModel.Tokens": {
"type": "Transitive",
- "resolved": "8.8.0",
- "contentHash": "09hnbUJh/18gUmu5nCVFMvyzAFC4l1qyc4bwSJaKzUBqHN7aNDwmSx8dE3/MMJImbvnKq9rEtkkgnrS/OUBtjA==",
+ "resolved": "8.11.0",
+ "contentHash": "E0iKSD9vv9X+tbHGriMTLkSNK/OOjxOPuf1dt9q32d25Ig+OZaidUqDoUTSS3mWTvPw+x5oXrCTHtDatbzRzTQ==",
"dependencies": {
- "Microsoft.Extensions.Logging.Abstractions": "8.0.2",
- "Microsoft.IdentityModel.Logging": "8.8.0"
+ "Microsoft.Extensions.Logging.Abstractions": "8.0.0",
+ "Microsoft.IdentityModel.Logging": "8.11.0"
}
},
"Microsoft.Net.Http.Headers": {
@@ -782,6 +764,11 @@
"resolved": "4.6.0",
"contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
},
+ "System.ComponentModel.Annotations": {
+ "type": "Transitive",
+ "resolved": "5.0.0",
+ "contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg=="
+ },
"System.IdentityModel.Tokens.Jwt": {
"type": "Transitive",
"resolved": "8.0.1",
@@ -842,7 +829,10 @@
"FluentValidation": "[11.11.0, )",
"MediatR": "[12.4.1, )",
"MediatR.Behaviors.Authorization": "[12.2.0, )",
+ "Microsoft.AspNetCore.Authentication.JwtBearer": "[9.0.5, )",
"Microsoft.Extensions.Logging": "[9.0.4, )",
+ "Microsoft.IdentityModel.JsonWebTokens": "[8.11.0, )",
+ "Microsoft.IdentityModel.Tokens": "[8.11.0, )",
"Newtonsoft.Json": "[13.0.3, )",
"QuikGraph": "[2.5.0, )",
"System.Linq.Dynamic.Core": "[1.6.2, )"
@@ -851,19 +841,6 @@
"domain": {
"type": "Project"
},
- "identity": {
- "type": "Project",
- "dependencies": {
- "Application": "[1.0.0, )",
- "Microsoft.AspNetCore.Authentication.JwtBearer": "[9.0.4, )",
- "Microsoft.AspNetCore.Identity": "[2.3.1, )",
- "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "[9.0.4, )",
- "Microsoft.Extensions.Options": "[9.0.4, )",
- "Microsoft.IdentityModel.JsonWebTokens": "[8.8.0, )",
- "Microsoft.IdentityModel.Tokens": "[8.8.0, )",
- "Npgsql.EntityFrameworkCore.PostgreSQL": "[9.0.4, )"
- }
- },
"infrastructure": {
"type": "Project",
"dependencies": {
diff --git a/src/Domain/Entities/Account.cs b/src/Domain/Entities/Account.cs
new file mode 100644
index 0000000..b477df4
--- /dev/null
+++ b/src/Domain/Entities/Account.cs
@@ -0,0 +1,16 @@
+namespace cuqmbr.TravelGuide.Domain.Entities;
+
+public sealed class Account : EntityBase
+{
+ public string Username { get; set; }
+
+ public string Email { get; set; }
+
+ public string PasswordHash { get; set; }
+
+ public string PasswordSalt { get; set; }
+
+ public ICollection AccountRoles { get; set; }
+
+ public ICollection RefreshTokens { get; set; }
+}
diff --git a/src/Domain/Entities/AccountRole.cs b/src/Domain/Entities/AccountRole.cs
new file mode 100644
index 0000000..fd28b0d
--- /dev/null
+++ b/src/Domain/Entities/AccountRole.cs
@@ -0,0 +1,12 @@
+namespace cuqmbr.TravelGuide.Domain.Entities;
+
+public sealed class AccountRole : EntityBase
+{
+ public long AccountId { get; set; }
+
+ public Account Account { get; set; }
+
+ public long RoleId { get; set; }
+
+ public Role Role { get; set; }
+}
diff --git a/src/Domain/Entities/RefreshToken.cs b/src/Domain/Entities/RefreshToken.cs
new file mode 100644
index 0000000..833d0e0
--- /dev/null
+++ b/src/Domain/Entities/RefreshToken.cs
@@ -0,0 +1,20 @@
+namespace cuqmbr.TravelGuide.Domain.Entities;
+
+public class RefreshToken : EntityBase
+{
+ public string Value { get; set; } = null!;
+
+ public DateTimeOffset CreationTime { get; set; }
+
+ public DateTimeOffset ExpirationTime { get; set; }
+
+ public DateTimeOffset? RevocationTime { get; set; }
+
+ public bool IsExpired => DateTimeOffset.UtcNow >= ExpirationTime;
+
+ public bool IsActive => RevocationTime == null && !IsExpired;
+
+ public long AccountId { get; set; }
+
+ public Account Account { get; set; }
+}
diff --git a/src/Domain/Entities/Role.cs b/src/Domain/Entities/Role.cs
new file mode 100644
index 0000000..a0b4539
--- /dev/null
+++ b/src/Domain/Entities/Role.cs
@@ -0,0 +1,10 @@
+using cuqmbr.TravelGuide.Domain.Enums;
+
+namespace cuqmbr.TravelGuide.Domain.Entities;
+
+public sealed class Role : EntityBase
+{
+ public IdentityRole Value { get; set; }
+
+ public ICollection AccountRoles { get; set; }
+}
diff --git a/src/Application/Common/Models/IdentityRole.cs b/src/Domain/Enums/IdentityRole.cs
similarity index 52%
rename from src/Application/Common/Models/IdentityRole.cs
rename to src/Domain/Enums/IdentityRole.cs
index 5636e3b..4424fb0 100644
--- a/src/Application/Common/Models/IdentityRole.cs
+++ b/src/Domain/Enums/IdentityRole.cs
@@ -1,11 +1,11 @@
-using cuqmbr.TravelGuide.Domain.Enums;
-
-namespace cuqmbr.TravelGuide.Application.Common.Models;
+namespace cuqmbr.TravelGuide.Domain.Enums;
public abstract class IdentityRole : Enumeration
{
public static readonly IdentityRole Administrator = new AdministratorRole();
public static readonly IdentityRole User = new UserRole();
+ public static readonly IdentityRole CompanyOwner = new CompanyOwnerRole();
+ public static readonly IdentityRole CompanyEmployee = new CompanyEmployeeRole();
protected IdentityRole(int value, string name) : base(value, name) { }
@@ -18,4 +18,14 @@ public abstract class IdentityRole : Enumeration
{
public UserRole() : base(1, "user") { }
}
+
+ private sealed class CompanyOwnerRole : IdentityRole
+ {
+ public CompanyOwnerRole() : base(2, "company_owner") { }
+ }
+
+ private sealed class CompanyEmployeeRole : IdentityRole
+ {
+ public CompanyEmployeeRole() : base(3, "company_employee") { }
+ }
}
diff --git a/src/HttpApi/Controllers/AuthenticationController.cs b/src/HttpApi/Controllers/AuthenticationController.cs
index ecb2a62..6ee61b4 100644
--- a/src/HttpApi/Controllers/AuthenticationController.cs
+++ b/src/HttpApi/Controllers/AuthenticationController.cs
@@ -4,10 +4,6 @@ using cuqmbr.TravelGuide.Application.Authenticaion.Queries.Login;
using cuqmbr.TravelGuide.Application.Authenticaion.Commands.Register;
using cuqmbr.TravelGuide.Application.Authenticaion.Commands.RenewAccessToken;
using cuqmbr.TravelGuide.Application.Authenticaion.Commands.RevokeRefreshToken;
-using cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RenewAccessTokenWithCookie;
-using cuqmbr.TravelGuide.Application.Authenticaion.Commands
- .RevokeRefreshTokenWithCookie;
namespace cuqmbr.TravelGuide.HttpApi.Controllers;
@@ -30,28 +26,6 @@ public class AuthenticationController : ControllerBase
return await Mediator.Send(query, cancellationToken);
}
- // [HttpPost("loginWithCookie")]
- // public async Task LoginWithCookie(
- // [FromBody] LoginQuery query,
- // CancellationToken cancellationToken)
- // {
- // var tokens = await Mediator.Send(query, cancellationToken);
- //
- // HttpContext.Response.Cookies.Delete("refreshToken");
- //
- // var cookieOptions = new CookieOptions()
- // {
- // Path = "/",
- // Expires = DateTimeOffset.MaxValue,
- // HttpOnly = true
- // };
- //
- // HttpContext.Response.Cookies.Append(
- // "refreshToken", tokens.RefreshToken, cookieOptions);
- //
- // return tokens;
- // }
-
[HttpPost("renewAccessToken")]
public async Task RenewAccessToken(
[FromBody] RenewAccessTokenCommand command,
@@ -60,14 +34,6 @@ public class AuthenticationController : ControllerBase
return await Mediator.Send(command, cancellationToken);
}
- // [HttpPost("renewAccessTokenWithCookie")]
- // public async Task RenewAccessTokenWithCookie(
- // [FromBody] RenewAccessTokenWithCookieCommand command,
- // CancellationToken cancellationToken)
- // {
- // return await Mediator.Send(command, cancellationToken);
- // }
-
[HttpPost("revokeRefreshToken")]
public async Task RevokeRefreshToken(
[FromBody] RevokeRefreshTokenCommand command,
@@ -75,13 +41,4 @@ public class AuthenticationController : ControllerBase
{
await Mediator.Send(command, cancellationToken);
}
-
- // [HttpPost("revokeRefreshTokenWithCookie")]
- // public async Task RevokeRefreshTokenWithCookie(
- // [FromBody] RevokeRefreshTokenWithCookieCommand command,
- // CancellationToken cancellationToken)
- // {
- // await Mediator.Send(command, cancellationToken);
- // HttpContext.Response.Cookies.Delete("refreshToken");
- // }
}
diff --git a/src/HttpApi/Controllers/IdentityController.cs b/src/HttpApi/Controllers/IdentityController.cs
new file mode 100644
index 0000000..bacb072
--- /dev/null
+++ b/src/HttpApi/Controllers/IdentityController.cs
@@ -0,0 +1,242 @@
+using Microsoft.AspNetCore.Mvc;
+using Swashbuckle.AspNetCore.Annotations;
+using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.ViewModels;
+using cuqmbr.TravelGuide.Domain.Enums;
+using cuqmbr.TravelGuide.Application.Identity.Roles.Queries.GetRolesPage;
+using cuqmbr.TravelGuide.Application.Identity.Accounts;
+using cuqmbr.TravelGuide.Application.Identity.Accounts.ViewModels;
+using cuqmbr.TravelGuide.Application.Identity.Accounts.Commands.AddAccount;
+// using cuqmbr.TravelGuide.Application.Identity.Commands.AddIdentity;
+// using cuqmbr.TravelGuide.Application.Identity.Queries.GetIdentityPage;
+// using cuqmbr.TravelGuide.Application.Identity.Queries.GetIdentity;
+// using cuqmbr.TravelGuide.Application.Identity.Commands.UpdateIdentity;
+// using cuqmbr.TravelGuide.Application.Identity.Commands.DeleteIdentity;
+// using cuqmbr.TravelGuide.Application.Identity.ViewModels;
+
+namespace cuqmbr.TravelGuide.HttpApi.Controllers;
+
+[Route("identity")]
+public class IdentityController : ControllerBase
+{
+ [HttpGet("roles")]
+ [SwaggerOperation("Get a list of all roles")]
+ [SwaggerResponse(
+ StatusCodes.Status200OK, "Request successful",
+ typeof(PaginatedList))]
+ [SwaggerResponse(
+ StatusCodes.Status400BadRequest, "Input data validation error",
+ typeof(HttpValidationProblemDetails))]
+ [SwaggerResponse(
+ StatusCodes.Status401Unauthorized, "Unauthorized to perform an action",
+ typeof(ProblemDetails))]
+ [SwaggerResponse(
+ StatusCodes.Status403Forbidden,
+ "Not enough privileges to perform an action",
+ typeof(ProblemDetails))]
+ [SwaggerResponse(
+ StatusCodes.Status500InternalServerError, "Internal server error",
+ typeof(ProblemDetails))]
+ public async Task> GetRolesPage(
+ [FromQuery] PageQuery pageQuery, [FromQuery] SearchQuery searchQuery,
+ CancellationToken cancellationToken)
+ {
+ return await Mediator.Send(
+ new GetRolesPageQuery()
+ {
+ PageNumber = pageQuery.PageNumber,
+ PageSize = pageQuery.PageSize,
+ Search = searchQuery.Search
+ },
+ cancellationToken);
+ }
+
+
+
+
+ [HttpPost("accounts")]
+ [SwaggerOperation("Add an account")]
+ [SwaggerResponse(
+ StatusCodes.Status201Created, "Object successfuly created",
+ typeof(AccountDto))]
+ [SwaggerResponse(
+ StatusCodes.Status400BadRequest, "Object already exists",
+ typeof(ProblemDetails))]
+ [SwaggerResponse(
+ StatusCodes.Status400BadRequest, "Input data validation error",
+ typeof(HttpValidationProblemDetails))]
+ [SwaggerResponse(
+ StatusCodes.Status401Unauthorized, "Unauthorized to perform an action",
+ typeof(ProblemDetails))]
+ [SwaggerResponse(
+ StatusCodes.Status403Forbidden,
+ "Not enough privileges to perform an action",
+ typeof(ProblemDetails))]
+ [SwaggerResponse(
+ StatusCodes.Status404NotFound, "Parent object not found",
+ typeof(ProblemDetails))]
+ [SwaggerResponse(
+ StatusCodes.Status500InternalServerError, "Internal server error",
+ typeof(ProblemDetails))]
+ public async Task> Add(
+ [FromBody] AddAccountViewModel viewModel,
+ CancellationToken cancellationToken)
+ {
+ return StatusCode(
+ StatusCodes.Status201Created,
+ await Mediator.Send(
+ new AddAccountCommand()
+ {
+ Email = viewModel.Email,
+ Password = viewModel.Password,
+ Roles = viewModel.Roles
+ .Select(s => IdentityRole.FromName(s))
+ .ToArray()
+ },
+ cancellationToken));
+ }
+
+
+
+
+ // [HttpPost]
+ // [SwaggerOperation("Add an identity")]
+ // [SwaggerResponse(
+ // StatusCodes.Status201Created, "Object successfuly created",
+ // typeof(IdentityDto))]
+ // [SwaggerResponse(
+ // StatusCodes.Status400BadRequest, "Object already exists",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status400BadRequest, "Input data validation error",
+ // typeof(HttpValidationProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status401Unauthorized, "Unauthorized to perform an action",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status403Forbidden,
+ // "Not enough privileges to perform an action",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status404NotFound, "Parent object not found",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status500InternalServerError, "Internal server error",
+ // typeof(ProblemDetails))]
+ // public async Task> Add(
+ // [FromBody] AddIdentityViewModel viewModel,
+ // CancellationToken cancellationToken)
+ // {
+ // return StatusCode(
+ // StatusCodes.Status201Created,
+ // await Mediator.Send(
+ // new AddIdentityCommand()
+ // {
+ // Name = viewModel.Name,
+ // Longitude = viewModel.Longitude,
+ // Latitude = viewModel.Latitude,
+ // VehicleType = VehicleType.FromName(viewModel.VehicleType),
+ // CityGuid = viewModel.CityUuid
+ // },
+ // cancellationToken));
+ // }
+ //
+ // [HttpGet("{uuid:guid}")]
+ // [SwaggerOperation("Get an identity by uuid")]
+ // [SwaggerResponse(
+ // StatusCodes.Status200OK, "Request successful", typeof(IdentityDto))]
+ // [SwaggerResponse(
+ // StatusCodes.Status400BadRequest, "Input data validation error",
+ // typeof(HttpValidationProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status401Unauthorized, "Unauthorized to perform an action",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status403Forbidden,
+ // "Not enough privileges to perform an action",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status404NotFound, "Object not found", typeof(IdentityDto))]
+ // [SwaggerResponse(
+ // StatusCodes.Status500InternalServerError, "Internal server error",
+ // typeof(ProblemDetails))]
+ // public async Task Get(
+ // [FromRoute] Guid uuid,
+ // CancellationToken cancellationToken)
+ // {
+ // return await Mediator.Send(new GetIdentityQuery() { Guid = uuid },
+ // cancellationToken);
+ // }
+ //
+ // [HttpPut("{uuid:guid}")]
+ // [SwaggerOperation("Update an identity")]
+ // [SwaggerResponse(
+ // StatusCodes.Status200OK, "Request successful", typeof(IdentityDto))]
+ // [SwaggerResponse(
+ // StatusCodes.Status400BadRequest, "Object already exists",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status400BadRequest, "Input data validation error",
+ // typeof(HttpValidationProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status401Unauthorized, "Unauthorized to perform an action",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status403Forbidden,
+ // "Not enough privileges to perform an action",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status404NotFound, "Object not found", typeof(IdentityDto))]
+ // [SwaggerResponse(
+ // StatusCodes.Status404NotFound, "Parent object not found",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status500InternalServerError, "Internal server error",
+ // typeof(ProblemDetails))]
+ // public async Task Update(
+ // [FromRoute] Guid uuid,
+ // [FromBody] UpdateIdentityViewModel viewModel,
+ // CancellationToken cancellationToken)
+ // {
+ // return await Mediator.Send(
+ // new UpdateIdentityCommand()
+ // {
+ // Guid = uuid,
+ // Name = viewModel.Name,
+ // Longitude = viewModel.Longitude,
+ // Latitude = viewModel.Latitude,
+ // VehicleType = VehicleType.FromName(viewModel.VehicleType),
+ // CityGuid = viewModel.CityUuid
+ // },
+ // cancellationToken);
+ // }
+ //
+ // [HttpDelete("{uuid:guid}")]
+ // [SwaggerOperation("Delete an identity")]
+ // [SwaggerResponse(StatusCodes.Status204NoContent, "Request successful")]
+ // [SwaggerResponse(
+ // StatusCodes.Status400BadRequest, "Input data validation error",
+ // typeof(HttpValidationProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status401Unauthorized, "Unauthorized to perform an action",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status403Forbidden,
+ // "Not enough privileges to perform an action",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status404NotFound, "Object not found",
+ // typeof(ProblemDetails))]
+ // [SwaggerResponse(
+ // StatusCodes.Status500InternalServerError, "Internal server error",
+ // typeof(ProblemDetails))]
+ // public async Task Delete(
+ // [FromRoute] Guid uuid,
+ // CancellationToken cancellationToken)
+ // {
+ // await Mediator.Send(
+ // new DeleteIdentityCommand() { Guid = uuid },
+ // cancellationToken);
+ // return StatusCode(StatusCodes.Status204NoContent);
+ // }
+}
diff --git a/src/HttpApi/Controllers/TestsController.cs b/src/HttpApi/Controllers/TestsController.cs
index be91e8b..3e2abf0 100644
--- a/src/HttpApi/Controllers/TestsController.cs
+++ b/src/HttpApi/Controllers/TestsController.cs
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Persistence;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Application.Common.Persistence;
namespace cuqmbr.TravelGuide.HttpApi.Controllers;
diff --git a/src/HttpApi/Middlewares/ThreadCultureSetterMiddleware.cs b/src/HttpApi/Middlewares/ThreadCultureSetterMiddleware.cs
index 3f245fb..3f7e4fa 100644
--- a/src/HttpApi/Middlewares/ThreadCultureSetterMiddleware.cs
+++ b/src/HttpApi/Middlewares/ThreadCultureSetterMiddleware.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using System.Globalization;
namespace cuqmbr.TravelGuide.HttpApi.Middlewares;
diff --git a/src/HttpApi/Program.cs b/src/HttpApi/Program.cs
index 015f880..c708d32 100644
--- a/src/HttpApi/Program.cs
+++ b/src/HttpApi/Program.cs
@@ -1,10 +1,9 @@
using cuqmbr.TravelGuide.Configuration.Persistence;
using cuqmbr.TravelGuide.Configuration.Application;
using cuqmbr.TravelGuide.Configuration.Infrastructure;
-using cuqmbr.TravelGuide.Configuration.Identity;
using cuqmbr.TravelGuide.Configuration.Configuration;
using cuqmbr.TravelGuide.Configuration.Logging;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.HttpApi.Services;
using cuqmbr.TravelGuide.HttpApi.HostedServices;
using cuqmbr.TravelGuide.HttpApi.Middlewares;
@@ -24,11 +23,11 @@ services.ConfigureConfiguration(args);
services.ConfigureLogging();
-services.ConfigurePersistence();
-services.ConfigureIdentity();
services.ConfigureInfrastructure();
+services.ConfigurePersistence();
services.ConfigureApplication();
+services.AddHttpContextAccessor();
services.AddScoped();
services.AddScoped();
services.AddScoped();
diff --git a/src/HttpApi/Services/AspNetSessionCultureService.cs b/src/HttpApi/Services/AspNetSessionCultureService.cs
index 1c4ef7e..7a7d614 100644
--- a/src/HttpApi/Services/AspNetSessionCultureService.cs
+++ b/src/HttpApi/Services/AspNetSessionCultureService.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using System.Globalization;
namespace cuqmbr.TravelGuide.HttpApi.Services;
diff --git a/src/HttpApi/Services/AspNetSessionCurrencyService.cs b/src/HttpApi/Services/AspNetSessionCurrencyService.cs
index 8b28990..91e4b68 100644
--- a/src/HttpApi/Services/AspNetSessionCurrencyService.cs
+++ b/src/HttpApi/Services/AspNetSessionCurrencyService.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
using cuqmbr.TravelGuide.Domain.Enums;
namespace cuqmbr.TravelGuide.HttpApi.Services;
diff --git a/src/HttpApi/Services/AspNetSessionTimeZoneService.cs b/src/HttpApi/Services/AspNetSessionTimeZoneService.cs
index 9feb264..55acb54 100644
--- a/src/HttpApi/Services/AspNetSessionTimeZoneService.cs
+++ b/src/HttpApi/Services/AspNetSessionTimeZoneService.cs
@@ -1,4 +1,4 @@
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
+using cuqmbr.TravelGuide.Application.Common.Services;
namespace cuqmbr.TravelGuide.HttpApi.Services;
diff --git a/src/HttpApi/Services/AspNetSessionUserService.cs b/src/HttpApi/Services/AspNetSessionUserService.cs
index eed5afc..2f9c8fd 100644
--- a/src/HttpApi/Services/AspNetSessionUserService.cs
+++ b/src/HttpApi/Services/AspNetSessionUserService.cs
@@ -1,6 +1,6 @@
using System.IdentityModel.Tokens.Jwt;
-using cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
-using cuqmbr.TravelGuide.Application.Common.Models;
+using cuqmbr.TravelGuide.Application.Common.Services;
+using cuqmbr.TravelGuide.Domain.Enums;
namespace cuqmbr.TravelGuide.HttpApi.Services;
@@ -13,7 +13,7 @@ public sealed class AspNetSessionUserService : SessionUserService
_httpContext = httpContextAccessor.HttpContext;
}
- public int? Id
+ public Guid? Guid
{
get
{
@@ -22,16 +22,16 @@ public sealed class AspNetSessionUserService : SessionUserService
.Any(p => p.Value == JwtRegisteredClaimNames.Sub))
?.Value;
- var parsed = int.TryParse(claimValue, out var id);
+ var parsed = System.Guid.TryParse(claimValue, out var guid);
- return parsed ? id : null;
+ return parsed ? guid : null;
}
}
- public Guid? Uuid => Guid.Parse(_httpContext.User.Claims
+ public string? Username => _httpContext.User.Claims
.FirstOrDefault(c => c.Properties
- .Any(p => p.Value.Equals("uuid")))
- ?.Value);
+ .Any(p => p.Value == JwtRegisteredClaimNames.Nickname))
+ ?.Value;
public string? Email => _httpContext.User.Claims
.FirstOrDefault(c => c.Properties
@@ -48,6 +48,7 @@ public sealed class AspNetSessionUserService : SessionUserService
_httpContext.Request.Cookies["accessToken"] ??
_httpContext.Request.Headers["Authorization"]
.ToString()?.Replace("Bearer ", "");
+
public string? RefreshToken =>
_httpContext.Request.Cookies["refreshToken"];
}
diff --git a/src/HttpApi/appsettings.Development.json b/src/HttpApi/appsettings.Development.json
index 8f2afcb..81ff06d 100644
--- a/src/HttpApi/appsettings.Development.json
+++ b/src/HttpApi/appsettings.Development.json
@@ -14,6 +14,13 @@
"DefaultCultureName": "en-US",
"CacheDuration": "00:30:00"
},
+ "JsonWebToken": {
+ "Issuer": "https://api.travel-guide.cuqmbr.xyz",
+ "Audience": "https://travel-guide.cuqmbr.xyz",
+ "IssuerSigningKey": "a2c98dec80787a4e85ffb5bcbc24f7e4cc014d8a4fe43e9520480a50759164bc",
+ "AccessTokenValidity": "24:00:00",
+ "RefreshTokenValidity": "72:00:00"
+ },
"Infrastructure": {
"PaymentProcessing": {
"CallbackAddressBase": "https://api.travel-guide.cuqmbr.xyz",
@@ -24,18 +31,5 @@
}
}
}
- },
- "Identity": {
- "Datastore": {
- "Type": "postgresql",
- "ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000"
- },
- "JsonWebToken": {
- "Issuer": "https://api.travel-guide.cuqmbr.xyz",
- "Audience": "https://travel-guide.cuqmbr.xyz",
- "IssuerSigningKey": "a2c98dec80787a4e85ffb5bcbc24f7e4cc014d8a4fe43e9520480a50759164bc",
- "AccessTokenValidity": "24:00:00",
- "RefreshTokenValidity": "72:00:00"
- }
}
}
diff --git a/src/HttpApi/appsettings.json b/src/HttpApi/appsettings.json
index 8f2afcb..81ff06d 100644
--- a/src/HttpApi/appsettings.json
+++ b/src/HttpApi/appsettings.json
@@ -14,6 +14,13 @@
"DefaultCultureName": "en-US",
"CacheDuration": "00:30:00"
},
+ "JsonWebToken": {
+ "Issuer": "https://api.travel-guide.cuqmbr.xyz",
+ "Audience": "https://travel-guide.cuqmbr.xyz",
+ "IssuerSigningKey": "a2c98dec80787a4e85ffb5bcbc24f7e4cc014d8a4fe43e9520480a50759164bc",
+ "AccessTokenValidity": "24:00:00",
+ "RefreshTokenValidity": "72:00:00"
+ },
"Infrastructure": {
"PaymentProcessing": {
"CallbackAddressBase": "https://api.travel-guide.cuqmbr.xyz",
@@ -24,18 +31,5 @@
}
}
}
- },
- "Identity": {
- "Datastore": {
- "Type": "postgresql",
- "ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000"
- },
- "JsonWebToken": {
- "Issuer": "https://api.travel-guide.cuqmbr.xyz",
- "Audience": "https://travel-guide.cuqmbr.xyz",
- "IssuerSigningKey": "a2c98dec80787a4e85ffb5bcbc24f7e4cc014d8a4fe43e9520480a50759164bc",
- "AccessTokenValidity": "24:00:00",
- "RefreshTokenValidity": "72:00:00"
- }
}
}
diff --git a/src/HttpApi/packages.lock.json b/src/HttpApi/packages.lock.json
index 2d89b37..02503f2 100644
--- a/src/HttpApi/packages.lock.json
+++ b/src/HttpApi/packages.lock.json
@@ -192,8 +192,8 @@
},
"Microsoft.AspNetCore.Authentication.JwtBearer": {
"type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "0HgfWPfnjlzWFbW4pw6FYNuIMV8obVU+MUkiZ33g4UOpvZcmdWzdayfheKPZ5+EUly8SvfgW0dJwwIrW4IVLZQ==",
+ "resolved": "9.0.5",
+ "contentHash": "8J04KPX5NCo6j5AjY/rgeLTceMBJ8Sq4k+YNxN/7hCrbCH1iwHVw7VGGvlCscj615ewMX3jYDmxxLdutbSPOcA==",
"dependencies": {
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "8.0.1"
}
@@ -224,15 +224,15 @@
},
"Microsoft.AspNetCore.Cryptography.Internal": {
"type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "E4pHyEb2Ul5a6bIwraGtw9TN39a/C2asyVPEJoyItc0reV4Y26FsPcEdcXyKjBbP4kSz9iU1Cz4Yhx/aOFPpqA=="
+ "resolved": "2.3.0",
+ "contentHash": "/qy5r0CD40OccajzDmX3gBfqqxpAJkcXoqlVz0YR70x3gTRq/VuseDU/lZ5eh8vM+KCdmPFAtyGcRWxTyXxuYg=="
},
"Microsoft.AspNetCore.Cryptography.KeyDerivation": {
"type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "5v9Kj2arRrCftLKW80Hfj31HkNnjcKyw57lQhF84drvGxJlCR63J0zMM1sMM+Hc+KCQjuoDmHtjwN0uOT+X3ag==",
+ "resolved": "2.3.0",
+ "contentHash": "S7pph0JuBkgNqtyiIdLtQ5icZxmpX502zxxvHuMtM5W7IR3CKl1r/Cup+i6+E6B7IF3BeZYF4O3RbcA108syig==",
"dependencies": {
- "Microsoft.AspNetCore.Cryptography.Internal": "9.0.4"
+ "Microsoft.AspNetCore.Cryptography.Internal": "2.3.0"
}
},
"Microsoft.AspNetCore.DataProtection": {
@@ -326,15 +326,6 @@
"Microsoft.Extensions.Identity.Core": "2.3.0"
}
},
- "Microsoft.AspNetCore.Identity.EntityFrameworkCore": {
- "type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "IC3X6Db6H0cXdE2zGtyk/jmSwXhHbJZaiNpg7TNFV/Biu/NgO6l/GuwgE0D1U6U9pca00WsqxESkNov+WA77CA==",
- "dependencies": {
- "Microsoft.EntityFrameworkCore.Relational": "9.0.4",
- "Microsoft.Extensions.Identity.Stores": "9.0.4"
- }
- },
"Microsoft.AspNetCore.Metadata": {
"type": "Transitive",
"resolved": "9.0.0",
@@ -681,22 +672,13 @@
},
"Microsoft.Extensions.Identity.Core": {
"type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "KKfCsoIHFGZmmCEjZBPuvDW0pCjboMru/Z3vbEyC/OIwUVeKrdPugFyjc81i7rNSjcPcDxVvGl/Ks8HLelKocg==",
+ "resolved": "2.3.0",
+ "contentHash": "yR0eFnUbAM2k+q5QsX0NKinfShIe1B/aiHXEywiNT5Cs2MvEhxQIbIn5rWXnEAfmwW+i+t5D8odPSEHz/taIyQ==",
"dependencies": {
- "Microsoft.AspNetCore.Cryptography.KeyDerivation": "9.0.4",
- "Microsoft.Extensions.Logging": "9.0.4",
- "Microsoft.Extensions.Options": "9.0.4"
- }
- },
- "Microsoft.Extensions.Identity.Stores": {
- "type": "Transitive",
- "resolved": "9.0.4",
- "contentHash": "0F6lSngwyXzrv+qtX46nhHYBOlPxEzj0qyCCef1kvlyEYhbj8kBL13FuDk4nEPkzk1yVjZgsnXBG19+TrNdakQ==",
- "dependencies": {
- "Microsoft.Extensions.Caching.Abstractions": "9.0.4",
- "Microsoft.Extensions.Identity.Core": "9.0.4",
- "Microsoft.Extensions.Logging": "9.0.4"
+ "Microsoft.AspNetCore.Cryptography.KeyDerivation": "2.3.0",
+ "Microsoft.Extensions.Logging": "8.0.1",
+ "Microsoft.Extensions.Options": "8.0.2",
+ "System.ComponentModel.Annotations": "5.0.0"
}
},
"Microsoft.Extensions.Localization": {
@@ -793,23 +775,23 @@
},
"Microsoft.IdentityModel.Abstractions": {
"type": "Transitive",
- "resolved": "8.8.0",
- "contentHash": "0lKw+f3vkmV9t3PLe6sY3xPrYrHYiMRFxuOse5CMkKPxhQYiabpfJsuk6wX2RrVQ86Dn+t/8poHpH0nbp6sFvA=="
+ "resolved": "8.11.0",
+ "contentHash": "X92UuBmvHYtsVrD+R+senFn6wOtSVtliSZNTZI8oHD+WqhYLmLNlHH6avYcbXqEznozxshSYzD/DVAuz54jjtg=="
},
"Microsoft.IdentityModel.JsonWebTokens": {
"type": "Transitive",
- "resolved": "8.8.0",
- "contentHash": "lepOkZZTMfJCPSnWITXxV+4Wxb54g+9oIybs9YovlOzZWuR1i2DOpzaDgSe+piDJaGtnSrcUlcB9fZ5Swur7Uw==",
+ "resolved": "8.11.0",
+ "contentHash": "rLvApg2vqs/Kz5kVHwHUMAe3owInYrsPX8QP8CQktubX9R63P+J47nR/IOS4n6ddJCvGInUGRBKqcBGJtuA4Rw==",
"dependencies": {
- "Microsoft.IdentityModel.Tokens": "8.8.0"
+ "Microsoft.IdentityModel.Tokens": "8.11.0"
}
},
"Microsoft.IdentityModel.Logging": {
"type": "Transitive",
- "resolved": "8.8.0",
- "contentHash": "sUyoxzg/WBZobbFLJK8loT9IILKtS9ePmWu5B11ogQqhSHppE6SRZKw0fhI6Fd16X6ey52cbbWc2rvMBC98EQA==",
+ "resolved": "8.11.0",
+ "contentHash": "/JNOMdYOQ4Tgbdwu9GbEcRJEpzakizuECCE8dCgY5lKXyqZUdAKXyeq4zITgS81eZYThqjhQZUYaJxOPofbmrg==",
"dependencies": {
- "Microsoft.IdentityModel.Abstractions": "8.8.0"
+ "Microsoft.IdentityModel.Abstractions": "8.11.0"
}
},
"Microsoft.IdentityModel.Protocols": {
@@ -831,11 +813,11 @@
},
"Microsoft.IdentityModel.Tokens": {
"type": "Transitive",
- "resolved": "8.8.0",
- "contentHash": "09hnbUJh/18gUmu5nCVFMvyzAFC4l1qyc4bwSJaKzUBqHN7aNDwmSx8dE3/MMJImbvnKq9rEtkkgnrS/OUBtjA==",
+ "resolved": "8.11.0",
+ "contentHash": "E0iKSD9vv9X+tbHGriMTLkSNK/OOjxOPuf1dt9q32d25Ig+OZaidUqDoUTSS3mWTvPw+x5oXrCTHtDatbzRzTQ==",
"dependencies": {
- "Microsoft.Extensions.Logging.Abstractions": "8.0.2",
- "Microsoft.IdentityModel.Logging": "8.8.0"
+ "Microsoft.Extensions.Logging.Abstractions": "8.0.0",
+ "Microsoft.IdentityModel.Logging": "8.11.0"
}
},
"Microsoft.Net.Http.Headers": {
@@ -947,6 +929,11 @@
"resolved": "7.0.0",
"contentHash": "dQPcs0U1IKnBdRDBkrCTi1FoajSTBzLcVTpjO4MBCMC7f4pDOIPzgBoX8JjG7X6uZRJ8EBxsi8+DR1JuwjnzOQ=="
},
+ "System.ComponentModel.Annotations": {
+ "type": "Transitive",
+ "resolved": "5.0.0",
+ "contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg=="
+ },
"System.Composition": {
"type": "Transitive",
"resolved": "7.0.0",
@@ -1083,7 +1070,10 @@
"FluentValidation": "[11.11.0, )",
"MediatR": "[12.4.1, )",
"MediatR.Behaviors.Authorization": "[12.2.0, )",
+ "Microsoft.AspNetCore.Authentication.JwtBearer": "[9.0.5, )",
"Microsoft.Extensions.Logging": "[9.0.4, )",
+ "Microsoft.IdentityModel.JsonWebTokens": "[8.11.0, )",
+ "Microsoft.IdentityModel.Tokens": "[8.11.0, )",
"Newtonsoft.Json": "[13.0.3, )",
"QuikGraph": "[2.5.0, )",
"System.Linq.Dynamic.Core": "[1.6.2, )"
@@ -1096,7 +1086,6 @@
"AspNetCore.Localizer.Json": "[1.0.1, )",
"Domain": "[1.0.0, )",
"FluentValidation.DependencyInjectionExtensions": "[11.11.0, )",
- "Identity": "[1.0.0, )",
"Infrastructure": "[1.0.0, )",
"Microsoft.AspNetCore.Identity": "[2.3.1, )",
"Microsoft.EntityFrameworkCore.InMemory": "[9.0.4, )",
@@ -1116,19 +1105,6 @@
"domain": {
"type": "Project"
},
- "identity": {
- "type": "Project",
- "dependencies": {
- "Application": "[1.0.0, )",
- "Microsoft.AspNetCore.Authentication.JwtBearer": "[9.0.4, )",
- "Microsoft.AspNetCore.Identity": "[2.3.1, )",
- "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "[9.0.4, )",
- "Microsoft.Extensions.Options": "[9.0.4, )",
- "Microsoft.IdentityModel.JsonWebTokens": "[8.8.0, )",
- "Microsoft.IdentityModel.Tokens": "[8.8.0, )",
- "Npgsql.EntityFrameworkCore.PostgreSQL": "[9.0.4, )"
- }
- },
"infrastructure": {
"type": "Project",
"dependencies": {
diff --git a/src/Identity/ConfigurationOptions.cs b/src/Identity/ConfigurationOptions.cs
deleted file mode 100644
index 9bce7be..0000000
--- a/src/Identity/ConfigurationOptions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-namespace cuqmbr.TravelGuide.Identity;
-
-public sealed class ConfigurationOptions
-{
- public static string SectionName { get; } = "Identity";
-
- public Datastore Datastore { get; set; } = new();
-
- public JsonWebToken JsonWebToken { get; set; } = new();
-}
-
-public sealed class Datastore
-{
- public string Type { get; set; } = "inmemory";
-
- public string ConnectionString { get; set; } = "InMemory";
-
- public string PartitionName { get; set; } = "identity";
-
- public bool Migrate { get; set; } = true;
-}
-
-public sealed class JsonWebToken
-{
- public string Issuer { get; set; } = "localhost";
-
- public string Audience { get; set; } = "localhost";
-
- public string IssuerSigningKey { get; set; } = "change-me";
-
- public TimeSpan AccessTokenValidity { get; set; } = TimeSpan.FromMinutes(15);
-
- public TimeSpan RefreshTokenValidity { get; set; } = TimeSpan.FromDays(3);
-}
diff --git a/src/Identity/Exceptions/UnSupportedDatastoreException.cs b/src/Identity/Exceptions/UnSupportedDatastoreException.cs
deleted file mode 100644
index 7366911..0000000
--- a/src/Identity/Exceptions/UnSupportedDatastoreException.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace cuqmbr.TravelGuide.Identity.Exceptions;
-
-public class UnSupportedDatastoreException : Exception
-{
- public UnSupportedDatastoreException()
- : base() { }
-
- public UnSupportedDatastoreException(string message)
- : base(message) { }
-}
-
diff --git a/src/Identity/Identity.csproj b/src/Identity/Identity.csproj
deleted file mode 100644
index 53c2cb1..0000000
--- a/src/Identity/Identity.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- net9.0
- enable
- enable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
diff --git a/src/Identity/IdentitySeeder.cs b/src/Identity/IdentitySeeder.cs
deleted file mode 100644
index 15e7647..0000000
--- a/src/Identity/IdentitySeeder.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using Microsoft.AspNetCore.Identity;
-using IdentityUser = cuqmbr.TravelGuide.Identity.Models.IdentityUser;
-using IdentityRole = cuqmbr.TravelGuide.Identity.Models.IdentityRole;
-using Microsoft.Extensions.DependencyInjection;
-using IdentityRoleEnum = cuqmbr.TravelGuide.Application.Common.Models
- .IdentityRole;
-
-namespace cuqmbr.TravelGuide.Identity;
-
-public static class IdentitySeeder
-{
- public static void Seed(IServiceProvider serviceProvider)
- {
- using var userManager = serviceProvider
- .GetService>();
- userManager.UserValidators.Clear();
- userManager.PasswordValidators.Clear();
-
- using var roleManager = serviceProvider
- .GetService>();
- roleManager.RoleValidators.Clear();
-
- // Seed Roles
- foreach (var role in IdentityRoleEnum.Enumerations)
- {
- var roleString = role.Value.Name;
-
- var roleExists = roleManager.RoleExistsAsync(roleString).Result;
-
- if (roleExists)
- {
- continue;
- }
-
- roleManager.CreateAsync(new IdentityRole()
- {
- Name = roleString,
- ConcurrencyStamp = Guid.NewGuid().ToString("D")
- }).Wait();
- }
-
- // Seed Identity
- var users = new (string Email, string Password, IdentityRoleEnum[] Roles)[]
- {
- ("admin", "admin", new [] { IdentityRoleEnum.Administrator }),
- };
-
- foreach (var user in users)
- {
-
- var userExists = userManager
- .FindByEmailAsync(user.Email).Result is not null;
-
- if (userExists)
- {
- continue;
- }
-
- var newUser = new IdentityUser
- {
- Email = user.Email,
- NormalizedEmail = user.Email.ToUpper(),
- EmailConfirmed = true,
- SecurityStamp = Guid.NewGuid().ToString("D"),
- RefreshTokens = default!
- };
-
- var hashedPassword
- = userManager.PasswordHasher.HashPassword(newUser, user.Password);
- newUser.PasswordHash = hashedPassword;
-
- userManager
- .CreateAsync(newUser)
- .Wait();
-
- var userRoles = user.Roles.Select(x => x.Name);
-
- userManager
- .AddToRolesAsync(newUser, userRoles)
- .Wait();
- }
-
- }
-}
-
diff --git a/src/Identity/Models/IdentityRole.cs b/src/Identity/Models/IdentityRole.cs
deleted file mode 100644
index b1d9ee4..0000000
--- a/src/Identity/Models/IdentityRole.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace cuqmbr.TravelGuide.Identity.Models;
-
-public class IdentityRole : Microsoft.AspNetCore.Identity.IdentityRole
-{
- public string Uuid { get; set; } = Guid.NewGuid().ToString();
-}
diff --git a/src/Identity/Models/IdentityUser.cs b/src/Identity/Models/IdentityUser.cs
deleted file mode 100644
index ce9aad1..0000000
--- a/src/Identity/Models/IdentityUser.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace cuqmbr.TravelGuide.Identity.Models;
-
-public class IdentityUser : Microsoft.AspNetCore.Identity.IdentityUser
-{
- public string Uuid { get; set; } = Guid.NewGuid().ToString();
-
- public ICollection RefreshTokens { get; set; }
-}
diff --git a/src/Identity/Models/RefreshToken.cs b/src/Identity/Models/RefreshToken.cs
deleted file mode 100644
index a751096..0000000
--- a/src/Identity/Models/RefreshToken.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace cuqmbr.TravelGuide.Identity.Models;
-
-public class RefreshToken
-{
- public int Id { get; set; }
-
- public string Value { get; set; } = null!;
-
- public DateTimeOffset CreationTimestamp { get; set; }
-
- public DateTimeOffset ExpirationTimestamp { get; set; }
-
- public DateTimeOffset? RevokationTimestamp { get; set; }
-
- public bool IsExpired => DateTimeOffset.UtcNow >= ExpirationTimestamp;
-
- public bool IsActive => RevokationTimestamp is null && !IsExpired;
-
- public int IdentityUserId { get; set; }
-
- public IdentityUser IdentityUser { get; set; }
-}
-
diff --git a/src/Identity/Persistence/PostgreSql/Configurations/IdentityRoleClaimConfiguration.cs b/src/Identity/Persistence/PostgreSql/Configurations/IdentityRoleClaimConfiguration.cs
deleted file mode 100644
index 91c8229..0000000
--- a/src/Identity/Persistence/PostgreSql/Configurations/IdentityRoleClaimConfiguration.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace cuqmbr.TravelGuide.Identity.Persistence.PostgreSql.Configurations;
-
-public class IdentityRoleClaimConfiguration : IEntityTypeConfiguration>
-{
- public void Configure(EntityTypeBuilder> builder)
- {
- builder
- .ToTable("role_claims");
-
- builder
- .Property(rc => rc.Id)
- .HasColumnName("id");
-
- builder
- .Property(rc => rc.RoleId)
- .HasColumnName("role_id");
-
- builder
- .Property(rc => rc.ClaimType)
- .HasColumnName("claim_type");
-
- builder
- .Property(rc => rc.ClaimValue)
- .HasColumnName("claim_value");
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Configurations/IdentityRoleConfiguration.cs b/src/Identity/Persistence/PostgreSql/Configurations/IdentityRoleConfiguration.cs
deleted file mode 100644
index e8ee518..0000000
--- a/src/Identity/Persistence/PostgreSql/Configurations/IdentityRoleConfiguration.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using cuqmbr.TravelGuide.Identity.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace cuqmbr.TravelGuide.Identity.Persistence.PostgreSql.Configurations;
-
-public class IdentityRoleConfiguration : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- builder
- .ToTable("roles");
-
- builder
- .Property(r => r.Id)
- .HasColumnName("id");
-
- builder
- .Property(r => r.Uuid)
- .HasColumnName("uuid");
-
- builder
- .Property(r => r.Name)
- .HasColumnName("name");
-
- builder
- .Property(r => r.NormalizedName)
- .HasColumnName("normalized_name");
-
- builder
- .Property(r => r.ConcurrencyStamp)
- .HasColumnName("concurrency_stamp");
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserClaimConfiguration.cs b/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserClaimConfiguration.cs
deleted file mode 100644
index 863092f..0000000
--- a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserClaimConfiguration.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace cuqmbr.TravelGuide.Identity.Persistence.PostgreSql.Configurations;
-
-public class IdentityUserClaimConfiguration : IEntityTypeConfiguration>
-{
- public void Configure(EntityTypeBuilder> builder)
- {
- builder
- .ToTable("user_claims");
-
- builder
- .Property(uc => uc.Id)
- .HasColumnName("id");
-
- builder
- .Property(uc => uc.UserId)
- .HasColumnName("user_id");
-
- builder
- .Property(uc => uc.ClaimType)
- .HasColumnName("claim_type");
-
- builder
- .Property(uc => uc.ClaimValue)
- .HasColumnName("claim_value");
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserConfiguration.cs b/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserConfiguration.cs
deleted file mode 100644
index e99835c..0000000
--- a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserConfiguration.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using cuqmbr.TravelGuide.Identity.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace cuqmbr.TravelGuide.Identity.Persistence.PostgreSql.Configurations;
-
-public class IdentityUserConfiguration : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- builder
- .ToTable("users");
-
- builder
- .Property(u => u.Id)
- .HasColumnName("id");
-
- builder
- .Property(u => u.Uuid)
- .HasColumnName("uuid");
-
- builder
- .Ignore(u => u.UserName);
-
- builder
- .Ignore(u => u.NormalizedUserName);
-
- builder
- .Property(u => u.Email)
- .HasColumnName("email");
-
- builder
- .Property(u => u.NormalizedEmail)
- .HasColumnName("normalized_email");
-
- builder
- .Property(u => u.EmailConfirmed)
- .HasColumnName("email_confirmed");
-
- builder
- .Property(u => u.PasswordHash)
- .HasColumnName("password_hash");
-
- builder
- .Property(u => u.SecurityStamp)
- .HasColumnName("security_stamp");
-
- builder
- .Property(u => u.ConcurrencyStamp)
- .HasColumnName("concurrency_stamp");
-
- builder
- .Ignore(u => u.PhoneNumber);
-
- builder
- .Ignore(u => u.PhoneNumberConfirmed);
-
- builder
- .Property(u => u.TwoFactorEnabled)
- .HasColumnName("two_factor_enabled");
-
- builder
- .Property(u => u.LockoutEnabled)
- .HasColumnName("lockout_enabled");
-
- builder
- .Property(u => u.LockoutEnd)
- .HasColumnName("lockout_end");
-
- builder
- .Property(u => u.AccessFailedCount)
- .HasColumnName("access_failed_count");
-
- builder
- .OwnsMany(u => u.RefreshTokens,
- refreshToken =>
- {
- refreshToken
- .ToTable("user_refresh_tokens");
-
- refreshToken
- .HasKey(rt => rt.Id)
- .HasName("id");
-
- refreshToken
- .WithOwner(rt => rt.IdentityUser)
- .HasForeignKey(rt => rt.IdentityUserId)
- .HasConstraintName("fk_identityUserRefreshTokens_identityUser_userId");
-
- refreshToken
- .Property(rt => rt.Id)
- .HasColumnName("id")
- .HasColumnType("int")
- .IsRequired();
-
- refreshToken
- .Property(rt => rt.IdentityUserId)
- .HasColumnName("user_id")
- .HasColumnType("int")
- .IsRequired();
-
- refreshToken
- .Property(rt => rt.Value)
- .HasColumnName("value")
- .HasColumnType("varchar(256)")
- .IsRequired();
-
- refreshToken
- .Property(rt => rt.CreationTimestamp)
- .HasColumnName("creation_timestamp_utc")
- .HasColumnType("timestamptz")
- .IsRequired();
-
- refreshToken
- .Property(rt => rt.ExpirationTimestamp)
- .HasColumnName("expiration_timestamp_utc")
- .HasColumnType("timestamptz")
- .IsRequired();
-
- refreshToken
- .Property(rt => rt.RevokationTimestamp)
- .HasColumnName("revokation_timestamp_utc")
- .HasColumnType("timestamptz")
- .IsRequired(false);
- }
- );
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserLoginConfiguration.cs b/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserLoginConfiguration.cs
deleted file mode 100644
index 3464a1c..0000000
--- a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserLoginConfiguration.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace cuqmbr.TravelGuide.Identity.Persistence.PostgreSql.Configurations;
-
-public class IdentityUserLoginConfiguration : IEntityTypeConfiguration>
-{
- public void Configure(EntityTypeBuilder> builder)
- {
- builder
- .ToTable("user_logins");
-
- builder
- .Property(ul => ul.LoginProvider)
- .HasColumnName("login_provider");
-
- builder
- .Property(ul => ul.ProviderKey)
- .HasColumnName("provider_key");
-
- builder
- .Property(ul => ul.ProviderDisplayName)
- .HasColumnName("provider_display_name");
-
- builder
- .Property(ul => ul.UserId)
- .HasColumnName("user_id");
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserRoleConfiguration.cs b/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserRoleConfiguration.cs
deleted file mode 100644
index 70fee96..0000000
--- a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserRoleConfiguration.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace cuqmbr.TravelGuide.Identity.Persistence.PostgreSql.Configurations;
-
-public class IdentityUserRoleConfiguration : IEntityTypeConfiguration>
-{
- public void Configure(EntityTypeBuilder> builder)
- {
- builder
- .ToTable("user_roles");
-
- builder
- .Property(ur => ur.UserId)
- .HasColumnName("user_id");
-
- builder
- .Property(ur => ur.RoleId)
- .HasColumnName("role_id");
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserTokenConfiguration.cs b/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserTokenConfiguration.cs
deleted file mode 100644
index 6b91d44..0000000
--- a/src/Identity/Persistence/PostgreSql/Configurations/IdentityUserTokenConfiguration.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace cuqmbr.TravelGuide.Identity.Persistence.PostgreSql.Configurations;
-
-public class IdentityUserTokenConfiguration : IEntityTypeConfiguration>
-{
- public void Configure(EntityTypeBuilder> builder)
- {
- builder
- .ToTable("user_tokens");
-
- builder
- .Property(ut => ut.UserId)
- .HasColumnName("user_id");
-
- builder
- .Property(ut => ut.LoginProvider)
- .HasColumnName("login_provider");
-
- builder
- .Property(ut => ut.Name)
- .HasColumnName("name");
-
- builder
- .Property(ut => ut.Value)
- .HasColumnName("value");
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Migrations/20250423194315_Initial_migration.Designer.cs b/src/Identity/Persistence/PostgreSql/Migrations/20250423194315_Initial_migration.Designer.cs
deleted file mode 100644
index 5fd201a..0000000
--- a/src/Identity/Persistence/PostgreSql/Migrations/20250423194315_Initial_migration.Designer.cs
+++ /dev/null
@@ -1,355 +0,0 @@
-//
-using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-using cuqmbr.TravelGuide.Identity.Persistence.PostgreSql;
-
-#nullable disable
-
-namespace Identity.Persistence.PostgreSql.Migrations
-{
- [DbContext(typeof(PostgreSqlIdentityDbContext))]
- [Migration("20250423194315_Initial_migration")]
- partial class Initial_migration
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasDefaultSchema("identity")
- .HasAnnotation("ProductVersion", "9.0.4")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ClaimType")
- .HasColumnType("text")
- .HasColumnName("claim_type");
-
- b.Property("ClaimValue")
- .HasColumnType("text")
- .HasColumnName("claim_value");
-
- b.Property("RoleId")
- .HasColumnType("integer")
- .HasColumnName("role_id");
-
- b.HasKey("Id");
-
- b.HasIndex("RoleId");
-
- b.ToTable("role_claims", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ClaimType")
- .HasColumnType("text")
- .HasColumnName("claim_type");
-
- b.Property("ClaimValue")
- .HasColumnType("text")
- .HasColumnName("claim_value");
-
- b.Property("UserId")
- .HasColumnType("integer")
- .HasColumnName("user_id");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("user_claims", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
- {
- b.Property("LoginProvider")
- .HasColumnType("text")
- .HasColumnName("login_provider");
-
- b.Property("ProviderKey")
- .HasColumnType("text")
- .HasColumnName("provider_key");
-
- b.Property("ProviderDisplayName")
- .HasColumnType("text")
- .HasColumnName("provider_display_name");
-
- b.Property("UserId")
- .HasColumnType("integer")
- .HasColumnName("user_id");
-
- b.HasKey("LoginProvider", "ProviderKey");
-
- b.HasIndex("UserId");
-
- b.ToTable("user_logins", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
- {
- b.Property("UserId")
- .HasColumnType("integer")
- .HasColumnName("user_id");
-
- b.Property("RoleId")
- .HasColumnType("integer")
- .HasColumnName("role_id");
-
- b.HasKey("UserId", "RoleId");
-
- b.HasIndex("RoleId");
-
- b.ToTable("user_roles", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
- {
- b.Property("UserId")
- .HasColumnType("integer")
- .HasColumnName("user_id");
-
- b.Property("LoginProvider")
- .HasColumnType("text")
- .HasColumnName("login_provider");
-
- b.Property("Name")
- .HasColumnType("text")
- .HasColumnName("name");
-
- b.Property("Value")
- .HasColumnType("text")
- .HasColumnName("value");
-
- b.HasKey("UserId", "LoginProvider", "Name");
-
- b.ToTable("user_tokens", "identity");
- });
-
- modelBuilder.Entity("cuqmbr.TravelGuide.Identity.Models.IdentityRole", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ConcurrencyStamp")
- .IsConcurrencyToken()
- .HasColumnType("text")
- .HasColumnName("concurrency_stamp");
-
- b.Property("Name")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)")
- .HasColumnName("name");
-
- b.Property("NormalizedName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)")
- .HasColumnName("normalized_name");
-
- b.Property("Uuid")
- .IsRequired()
- .HasColumnType("text")
- .HasColumnName("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("NormalizedName")
- .IsUnique()
- .HasDatabaseName("RoleNameIndex");
-
- b.ToTable("roles", "identity");
- });
-
- modelBuilder.Entity("cuqmbr.TravelGuide.Identity.Models.IdentityUser", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("AccessFailedCount")
- .HasColumnType("integer")
- .HasColumnName("access_failed_count");
-
- b.Property("ConcurrencyStamp")
- .IsConcurrencyToken()
- .HasColumnType("text")
- .HasColumnName("concurrency_stamp");
-
- b.Property("Email")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)")
- .HasColumnName("email");
-
- b.Property("EmailConfirmed")
- .HasColumnType("boolean")
- .HasColumnName("email_confirmed");
-
- b.Property("LockoutEnabled")
- .HasColumnType("boolean")
- .HasColumnName("lockout_enabled");
-
- b.Property("LockoutEnd")
- .HasColumnType("timestamp with time zone")
- .HasColumnName("lockout_end");
-
- b.Property("NormalizedEmail")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)")
- .HasColumnName("normalized_email");
-
- b.Property("PasswordHash")
- .HasColumnType("text")
- .HasColumnName("password_hash");
-
- b.Property("SecurityStamp")
- .HasColumnType("text")
- .HasColumnName("security_stamp");
-
- b.Property("TwoFactorEnabled")
- .HasColumnType("boolean")
- .HasColumnName("two_factor_enabled");
-
- b.Property("Uuid")
- .IsRequired()
- .HasColumnType("text")
- .HasColumnName("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("NormalizedEmail")
- .HasDatabaseName("EmailIndex");
-
- b.ToTable("users", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
- {
- b.HasOne("cuqmbr.TravelGuide.Identity.Models.IdentityRole", null)
- .WithMany()
- .HasForeignKey("RoleId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
- {
- b.HasOne("cuqmbr.TravelGuide.Identity.Models.IdentityUser", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
- {
- b.HasOne("cuqmbr.TravelGuide.Identity.Models.IdentityUser", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
- {
- b.HasOne("cuqmbr.TravelGuide.Identity.Models.IdentityRole", null)
- .WithMany()
- .HasForeignKey("RoleId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("cuqmbr.TravelGuide.Identity.Models.IdentityUser", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
- {
- b.HasOne("cuqmbr.TravelGuide.Identity.Models.IdentityUser", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("cuqmbr.TravelGuide.Identity.Models.IdentityUser", b =>
- {
- b.OwnsMany("cuqmbr.TravelGuide.Identity.Models.RefreshToken", "RefreshTokens", b1 =>
- {
- b1.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id"));
-
- b1.Property("CreationTimestamp")
- .HasColumnType("timestamptz")
- .HasColumnName("creation_timestamp_utc");
-
- b1.Property("ExpirationTimestamp")
- .HasColumnType("timestamptz")
- .HasColumnName("expiration_timestamp_utc");
-
- b1.Property("IdentityUserId")
- .HasColumnType("int")
- .HasColumnName("user_id");
-
- b1.Property("RevokationTimestamp")
- .HasColumnType("timestamptz")
- .HasColumnName("revokation_timestamp_utc");
-
- b1.Property("Value")
- .IsRequired()
- .HasColumnType("varchar(256)")
- .HasColumnName("value");
-
- b1.HasKey("Id")
- .HasName("id");
-
- b1.HasIndex("IdentityUserId");
-
- b1.ToTable("user_refresh_tokens", "identity");
-
- b1.WithOwner("IdentityUser")
- .HasForeignKey("IdentityUserId")
- .HasConstraintName("fk_identityUserRefreshTokens_identityUser_userId");
-
- b1.Navigation("IdentityUser");
- });
-
- b.Navigation("RefreshTokens");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Migrations/20250423194315_Initial_migration.cs b/src/Identity/Persistence/PostgreSql/Migrations/20250423194315_Initial_migration.cs
deleted file mode 100644
index 035edce..0000000
--- a/src/Identity/Persistence/PostgreSql/Migrations/20250423194315_Initial_migration.cs
+++ /dev/null
@@ -1,281 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-namespace Identity.Persistence.PostgreSql.Migrations
-{
- ///
- public partial class Initial_migration : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.EnsureSchema(
- name: "identity");
-
- migrationBuilder.CreateTable(
- name: "roles",
- schema: "identity",
- columns: table => new
- {
- id = table.Column(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- uuid = table.Column(type: "text", nullable: false),
- name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
- normalized_name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
- concurrency_stamp = table.Column(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_roles", x => x.id);
- });
-
- migrationBuilder.CreateTable(
- name: "users",
- schema: "identity",
- columns: table => new
- {
- id = table.Column(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- uuid = table.Column(type: "text", nullable: false),
- email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
- normalized_email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
- email_confirmed = table.Column(type: "boolean", nullable: false),
- password_hash = table.Column(type: "text", nullable: true),
- security_stamp = table.Column(type: "text", nullable: true),
- concurrency_stamp = table.Column(type: "text", nullable: true),
- two_factor_enabled = table.Column(type: "boolean", nullable: false),
- lockout_end = table.Column(type: "timestamp with time zone", nullable: true),
- lockout_enabled = table.Column(type: "boolean", nullable: false),
- access_failed_count = table.Column(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_users", x => x.id);
- });
-
- migrationBuilder.CreateTable(
- name: "role_claims",
- schema: "identity",
- columns: table => new
- {
- id = table.Column(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- role_id = table.Column(type: "integer", nullable: false),
- claim_type = table.Column(type: "text", nullable: true),
- claim_value = table.Column(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_role_claims", x => x.id);
- table.ForeignKey(
- name: "FK_role_claims_roles_role_id",
- column: x => x.role_id,
- principalSchema: "identity",
- principalTable: "roles",
- principalColumn: "id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "user_claims",
- schema: "identity",
- columns: table => new
- {
- id = table.Column(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- user_id = table.Column(type: "integer", nullable: false),
- claim_type = table.Column(type: "text", nullable: true),
- claim_value = table.Column(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_user_claims", x => x.id);
- table.ForeignKey(
- name: "FK_user_claims_users_user_id",
- column: x => x.user_id,
- principalSchema: "identity",
- principalTable: "users",
- principalColumn: "id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "user_logins",
- schema: "identity",
- columns: table => new
- {
- login_provider = table.Column(type: "text", nullable: false),
- provider_key = table.Column(type: "text", nullable: false),
- provider_display_name = table.Column(type: "text", nullable: true),
- user_id = table.Column(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_user_logins", x => new { x.login_provider, x.provider_key });
- table.ForeignKey(
- name: "FK_user_logins_users_user_id",
- column: x => x.user_id,
- principalSchema: "identity",
- principalTable: "users",
- principalColumn: "id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "user_refresh_tokens",
- schema: "identity",
- columns: table => new
- {
- id = table.Column(type: "int", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- value = table.Column(type: "varchar(256)", nullable: false),
- creation_timestamp_utc = table.Column(type: "timestamptz", nullable: false),
- expiration_timestamp_utc = table.Column(type: "timestamptz", nullable: false),
- revokation_timestamp_utc = table.Column(type: "timestamptz", nullable: true),
- user_id = table.Column(type: "int", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("id", x => x.id);
- table.ForeignKey(
- name: "fk_identityUserRefreshTokens_identityUser_userId",
- column: x => x.user_id,
- principalSchema: "identity",
- principalTable: "users",
- principalColumn: "id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "user_roles",
- schema: "identity",
- columns: table => new
- {
- user_id = table.Column(type: "integer", nullable: false),
- role_id = table.Column(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_user_roles", x => new { x.user_id, x.role_id });
- table.ForeignKey(
- name: "FK_user_roles_roles_role_id",
- column: x => x.role_id,
- principalSchema: "identity",
- principalTable: "roles",
- principalColumn: "id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_user_roles_users_user_id",
- column: x => x.user_id,
- principalSchema: "identity",
- principalTable: "users",
- principalColumn: "id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "user_tokens",
- schema: "identity",
- columns: table => new
- {
- user_id = table.Column(type: "integer", nullable: false),
- login_provider = table.Column(type: "text", nullable: false),
- name = table.Column(type: "text", nullable: false),
- value = table.Column(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_user_tokens", x => new { x.user_id, x.login_provider, x.name });
- table.ForeignKey(
- name: "FK_user_tokens_users_user_id",
- column: x => x.user_id,
- principalSchema: "identity",
- principalTable: "users",
- principalColumn: "id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_role_claims_role_id",
- schema: "identity",
- table: "role_claims",
- column: "role_id");
-
- migrationBuilder.CreateIndex(
- name: "RoleNameIndex",
- schema: "identity",
- table: "roles",
- column: "normalized_name",
- unique: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_user_claims_user_id",
- schema: "identity",
- table: "user_claims",
- column: "user_id");
-
- migrationBuilder.CreateIndex(
- name: "IX_user_logins_user_id",
- schema: "identity",
- table: "user_logins",
- column: "user_id");
-
- migrationBuilder.CreateIndex(
- name: "IX_user_refresh_tokens_user_id",
- schema: "identity",
- table: "user_refresh_tokens",
- column: "user_id");
-
- migrationBuilder.CreateIndex(
- name: "IX_user_roles_role_id",
- schema: "identity",
- table: "user_roles",
- column: "role_id");
-
- migrationBuilder.CreateIndex(
- name: "EmailIndex",
- schema: "identity",
- table: "users",
- column: "normalized_email");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "role_claims",
- schema: "identity");
-
- migrationBuilder.DropTable(
- name: "user_claims",
- schema: "identity");
-
- migrationBuilder.DropTable(
- name: "user_logins",
- schema: "identity");
-
- migrationBuilder.DropTable(
- name: "user_refresh_tokens",
- schema: "identity");
-
- migrationBuilder.DropTable(
- name: "user_roles",
- schema: "identity");
-
- migrationBuilder.DropTable(
- name: "user_tokens",
- schema: "identity");
-
- migrationBuilder.DropTable(
- name: "roles",
- schema: "identity");
-
- migrationBuilder.DropTable(
- name: "users",
- schema: "identity");
- }
- }
-}
diff --git a/src/Identity/Persistence/PostgreSql/Migrations/PostgreSqlIdentityDbContextModelSnapshot.cs b/src/Identity/Persistence/PostgreSql/Migrations/PostgreSqlIdentityDbContextModelSnapshot.cs
deleted file mode 100644
index 6a55357..0000000
--- a/src/Identity/Persistence/PostgreSql/Migrations/PostgreSqlIdentityDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,352 +0,0 @@
-//
-using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-using cuqmbr.TravelGuide.Identity.Persistence.PostgreSql;
-
-#nullable disable
-
-namespace Identity.Persistence.PostgreSql.Migrations
-{
- [DbContext(typeof(PostgreSqlIdentityDbContext))]
- partial class PostgreSqlIdentityDbContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasDefaultSchema("identity")
- .HasAnnotation("ProductVersion", "9.0.4")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ClaimType")
- .HasColumnType("text")
- .HasColumnName("claim_type");
-
- b.Property("ClaimValue")
- .HasColumnType("text")
- .HasColumnName("claim_value");
-
- b.Property("RoleId")
- .HasColumnType("integer")
- .HasColumnName("role_id");
-
- b.HasKey("Id");
-
- b.HasIndex("RoleId");
-
- b.ToTable("role_claims", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ClaimType")
- .HasColumnType("text")
- .HasColumnName("claim_type");
-
- b.Property("ClaimValue")
- .HasColumnType("text")
- .HasColumnName("claim_value");
-
- b.Property("UserId")
- .HasColumnType("integer")
- .HasColumnName("user_id");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("user_claims", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
- {
- b.Property("LoginProvider")
- .HasColumnType("text")
- .HasColumnName("login_provider");
-
- b.Property("ProviderKey")
- .HasColumnType("text")
- .HasColumnName("provider_key");
-
- b.Property("ProviderDisplayName")
- .HasColumnType("text")
- .HasColumnName("provider_display_name");
-
- b.Property("UserId")
- .HasColumnType("integer")
- .HasColumnName("user_id");
-
- b.HasKey("LoginProvider", "ProviderKey");
-
- b.HasIndex("UserId");
-
- b.ToTable("user_logins", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
- {
- b.Property("UserId")
- .HasColumnType("integer")
- .HasColumnName("user_id");
-
- b.Property("RoleId")
- .HasColumnType("integer")
- .HasColumnName("role_id");
-
- b.HasKey("UserId", "RoleId");
-
- b.HasIndex("RoleId");
-
- b.ToTable("user_roles", "identity");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
- {
- b.Property("UserId")
- .HasColumnType("integer")
- .HasColumnName("user_id");
-
- b.Property("LoginProvider")
- .HasColumnType("text")
- .HasColumnName("login_provider");
-
- b.Property("Name")
- .HasColumnType("text")
- .HasColumnName("name");
-
- b.Property("Value")
- .HasColumnType("text")
- .HasColumnName("value");
-
- b.HasKey("UserId", "LoginProvider", "Name");
-
- b.ToTable("user_tokens", "identity");
- });
-
- modelBuilder.Entity("cuqmbr.TravelGuide.Identity.Models.IdentityRole", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ConcurrencyStamp")
- .IsConcurrencyToken()
- .HasColumnType("text")
- .HasColumnName("concurrency_stamp");
-
- b.Property("Name")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)")
- .HasColumnName("name");
-
- b.Property