Merge branch 'main' into stage
This commit is contained in:
2317
docs/model.ndm2
2317
docs/model.ndm2
File diff suppressed because it is too large
Load Diff
13
src/.idea/.idea.FrontOffice.BFF/.idea/.gitignore
generated
vendored
Normal file
13
src/.idea/.idea.FrontOffice.BFF/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/modules.xml
|
||||
/.idea.FrontOffice.BFF.iml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
1
src/.idea/.idea.FrontOffice.BFF/.idea/.name
generated
Normal file
1
src/.idea/.idea.FrontOffice.BFF/.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
||||
FrontOffice.BFF
|
||||
6
src/.idea/.idea.FrontOffice.BFF/.idea/copilot.data.migration.agent.xml
generated
Normal file
6
src/.idea/.idea.FrontOffice.BFF/.idea/copilot.data.migration.agent.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AgentMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
6
src/.idea/.idea.FrontOffice.BFF/.idea/copilot.data.migration.ask.xml
generated
Normal file
6
src/.idea/.idea.FrontOffice.BFF/.idea/copilot.data.migration.ask.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AskMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
6
src/.idea/.idea.FrontOffice.BFF/.idea/copilot.data.migration.ask2agent.xml
generated
Normal file
6
src/.idea/.idea.FrontOffice.BFF/.idea/copilot.data.migration.ask2agent.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Ask2AgentMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
6
src/.idea/.idea.FrontOffice.BFF/.idea/copilot.data.migration.edit.xml
generated
Normal file
6
src/.idea/.idea.FrontOffice.BFF/.idea/copilot.data.migration.edit.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EditMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
4
src/.idea/.idea.FrontOffice.BFF/.idea/encodings.xml
generated
Normal file
4
src/.idea/.idea.FrontOffice.BFF/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
src/.idea/.idea.FrontOffice.BFF/.idea/indexLayout.xml
generated
Normal file
8
src/.idea/.idea.FrontOffice.BFF/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
src/.idea/.idea.FrontOffice.BFF/.idea/vcs.xml
generated
Normal file
6
src/.idea/.idea.FrontOffice.BFF/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,15 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.0" />
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
|
||||
<PackageReference Include="Mapster" Version="7.4.0" />
|
||||
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.1" />
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FrontOffice.BFF.Domain\FrontOffice.BFF.Domain.csproj" />
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Commands.SetPasswordForUser;
|
||||
public record SetPasswordForUserCommand : IRequest<Unit>
|
||||
{
|
||||
//کلمه عبور فعلی
|
||||
public string? CurrentPassword { get; init; }
|
||||
//کلمه عبور
|
||||
public string NewPassword { get; init; }
|
||||
//تایید کلمه عبور
|
||||
public string ConfirmPassword { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Commands.SetPasswordForUser;
|
||||
public class SetPasswordForUserCommandHandler : IRequestHandler<SetPasswordForUserCommand, Unit>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public SetPasswordForUserCommandHandler(IApplicationContractContext context, ICurrentUserService currentUserService)
|
||||
{
|
||||
_context = context;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(SetPasswordForUserCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var setPasswordRequest = request.Adapt<SetPasswordForUserRequest>();
|
||||
setPasswordRequest.UserId = long.Parse(_currentUserService.UserId ?? throw new InvalidOperationException());
|
||||
await _context.User.SetPasswordForUserAsync(setPasswordRequest, cancellationToken: cancellationToken);
|
||||
return new Unit();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Commands.SetPasswordForUser;
|
||||
public class SetPasswordForUserCommandValidator : AbstractValidator<SetPasswordForUserCommand>
|
||||
{
|
||||
public SetPasswordForUserCommandValidator()
|
||||
{
|
||||
RuleFor(model => model.NewPassword)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.ConfirmPassword)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<SetPasswordForUserCommand>.CreateWithOptions((SetPasswordForUserCommand)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Commands.UpdateUser;
|
||||
|
||||
public class UpdateUserCommandHandler : IRequestHandler<UpdateUserCommand, Unit>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
@@ -12,7 +13,56 @@ public class UpdateUserCommandHandler : IRequestHandler<UpdateUserCommand, Unit>
|
||||
|
||||
public async Task<Unit> Handle(UpdateUserCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _context.User.UpdateUserAsync(request: request.Adapt<UpdateUserRequest>(), cancellationToken: cancellationToken);
|
||||
var updatingUserRequest = new UpdateUserRequest();
|
||||
var existUser = await _context.User.GetUserAsync(new GetUserRequest()
|
||||
{
|
||||
Id = request.Id
|
||||
}, cancellationToken: cancellationToken);
|
||||
if (existUser == null)
|
||||
throw new NotFoundException("User not found");
|
||||
|
||||
if (!string.IsNullOrEmpty(request.FirstName))
|
||||
{
|
||||
updatingUserRequest.FirstName = request.FirstName;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(request.LastName))
|
||||
{
|
||||
updatingUserRequest.LastName = request.LastName;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(request.NationalCode))
|
||||
{
|
||||
updatingUserRequest.NationalCode = request.NationalCode;
|
||||
}
|
||||
if (request.BirthDate.HasValue)
|
||||
{
|
||||
updatingUserRequest.BirthDate = Timestamp.FromDateTime(DateTime.SpecifyKind(request.BirthDate.Value, DateTimeKind.Utc));;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(request.AvatarPath))
|
||||
{
|
||||
updatingUserRequest.AvatarPath = request.AvatarPath;
|
||||
}
|
||||
// if (request.AvatarFile!= null)
|
||||
// {
|
||||
// }
|
||||
if (request.PushNotifications!=existUser.PushNotifications)
|
||||
{
|
||||
updatingUserRequest.PushNotifications = request.PushNotifications;
|
||||
}
|
||||
|
||||
if (request.EmailNotifications!=existUser.EmailNotifications)
|
||||
{
|
||||
updatingUserRequest.EmailNotifications = request.EmailNotifications;
|
||||
}
|
||||
|
||||
if (request.SmsNotifications!=existUser.SmsNotifications)
|
||||
{
|
||||
updatingUserRequest.SmsNotifications = request.SmsNotifications;
|
||||
}
|
||||
|
||||
await _context.User.UpdateUserAsync(request: request.Adapt<UpdateUserRequest>(),
|
||||
cancellationToken: cancellationToken);
|
||||
return Unit.Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
public record AdminGetJwtTokenQuery : IRequest<AdminGetJwtTokenResponseDto>
|
||||
{
|
||||
//نام کاربری
|
||||
public string Username { get; init; }
|
||||
//کلمه عبور
|
||||
public string Password { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
public class AdminGetJwtTokenQueryHandler : IRequestHandler<AdminGetJwtTokenQuery, AdminGetJwtTokenResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public AdminGetJwtTokenQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<AdminGetJwtTokenResponseDto> Handle(AdminGetJwtTokenQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.User.AdminGetJwtTokenAsync(request.Adapt<AdminGetJwtTokenRequest>(),
|
||||
cancellationToken: cancellationToken);
|
||||
return response.Adapt<AdminGetJwtTokenResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
public class AdminGetJwtTokenQueryValidator : AbstractValidator<AdminGetJwtTokenQuery>
|
||||
{
|
||||
public AdminGetJwtTokenQueryValidator()
|
||||
{
|
||||
RuleFor(model => model.Username)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Password)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<AdminGetJwtTokenQuery>.CreateWithOptions((AdminGetJwtTokenQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FrontOffice.BFF.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
public class AdminGetJwtTokenResponseDto
|
||||
{
|
||||
//توکن
|
||||
public string Token { get; set; }
|
||||
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Afrino.PYMSMicroservice.Protobuf" Version="0.0.11" />
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.117" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.118" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.72.0">
|
||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -31,8 +31,8 @@ public static class ConfigureServices
|
||||
jwtBearerOptions.RequireHttpsMetadata = false;
|
||||
jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateIssuer = false,//todo change to true in production
|
||||
ValidateAudience = false,//todo change to true in production
|
||||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidIssuer = configuration["JwtIssuer"],
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.11" />
|
||||
<PackageReference Include="KavenegarDotNetCore" Version="1.0.7" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using Grpc.Core.Interceptors;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using FrontOffice.BFF.Application.Common.Interfaces;
|
||||
|
||||
namespace FrontOffice.BFF.WebApi.Common.Behaviours;
|
||||
|
||||
public class LoggingBehaviour : Interceptor
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
public LoggingBehaviour(ILogger<LoggingBehaviour> logger, ICurrentUserService currentUserService)
|
||||
{
|
||||
_logger = logger;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
|
||||
public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
|
||||
TRequest request,
|
||||
ServerCallContext context,
|
||||
UnaryServerMethod<TRequest, TResponse> continuation)
|
||||
{
|
||||
var requestName = typeof(TRequest).Name;
|
||||
var userId = _currentUserService.UserId ?? string.Empty;
|
||||
_logger.LogInformation("gRPC Starting receiving call. Type/Method: {Type} / {Method} Request: {Name} {@UserId} {@Request}",
|
||||
MethodType.Unary, context.Method , requestName, userId, request);
|
||||
|
||||
try
|
||||
{
|
||||
return await continuation(request, context);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "gRPC Request: Unhandled Exception for Request {Name} {@Request}", requestName, request);
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Grpc.Core.Interceptors;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Diagnostics;
|
||||
using FrontOffice.BFF.Application.Common.Interfaces;
|
||||
|
||||
namespace FrontOffice.BFF.WebApi.Common.Behaviours;
|
||||
|
||||
public class PerformanceBehaviour : Interceptor
|
||||
{
|
||||
private readonly Stopwatch _timer;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
public PerformanceBehaviour(ILogger<PerformanceBehaviour> logger, ICurrentUserService currentUserService)
|
||||
{
|
||||
_timer = new Stopwatch();
|
||||
_logger = logger;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
|
||||
public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
|
||||
TRequest request,
|
||||
ServerCallContext context,
|
||||
UnaryServerMethod<TRequest, TResponse> continuation)
|
||||
{
|
||||
_timer.Start();
|
||||
|
||||
var response = await continuation(request, context);
|
||||
|
||||
_timer.Stop();
|
||||
|
||||
var elapsedMilliseconds = _timer.ElapsedMilliseconds;
|
||||
|
||||
if (elapsedMilliseconds > 500)
|
||||
{
|
||||
var requestName = typeof(TRequest).Name;
|
||||
var userId = _currentUserService.UserId ?? string.Empty;
|
||||
|
||||
_logger.LogWarning("gRPC Long Running Request: {Name} ({ElapsedMilliseconds} milliseconds) {@UserId} {@Request}",
|
||||
requestName, elapsedMilliseconds, userId, request);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>..\..\..</DockerfileContext>
|
||||
@@ -10,11 +10,11 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.54.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.54.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Grpc.Swagger" Version="0.3.8" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="6.3.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Grpc.Swagger" Version="0.9.11" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="9.0.2" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.BFF.WebApi.Common.Services;
|
||||
using FrontOffice.BFF.Application.UserCQ.Commands.UpdateUser;
|
||||
using FrontOffice.BFF.Application.UserCQ.Commands.DeleteUser;
|
||||
@@ -6,6 +5,10 @@ using FrontOffice.BFF.Application.UserCQ.Queries.GetUser;
|
||||
using FrontOffice.BFF.Application.UserCQ.Queries.GetAllUserByFilter;
|
||||
using FrontOffice.BFF.Application.UserCQ.Commands.CreateNewOtpToken;
|
||||
using FrontOffice.BFF.Application.UserCQ.Commands.VerifyOtpToken;
|
||||
using FrontOffice.BFF.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
using FrontOffice.BFF.Application.UserCQ.Commands.SetPasswordForUser;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
|
||||
namespace FrontOffice.BFF.WebApi.Services;
|
||||
public class UserService : UserContract.UserContractBase
|
||||
{
|
||||
@@ -15,6 +18,7 @@ public class UserService : UserContract.UserContractBase
|
||||
{
|
||||
_dispatchRequestToCQRS = dispatchRequestToCQRS;
|
||||
}
|
||||
[Authorize(Roles = "user")]
|
||||
public override async Task<Empty> UpdateUser(UpdateUserRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<UpdateUserRequest, UpdateUserCommand>(request, context);
|
||||
@@ -39,4 +43,12 @@ public class UserService : UserContract.UserContractBase
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<VerifyOtpTokenRequest, VerifyOtpTokenCommand, VerifyOtpTokenResponse>(request, context);
|
||||
}
|
||||
public override async Task<AdminGetJwtTokenResponse> AdminGetJwtToken(AdminGetJwtTokenRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<AdminGetJwtTokenRequest, AdminGetJwtTokenQuery, AdminGetJwtTokenResponse>(request, context);
|
||||
}
|
||||
public override async Task<Empty> SetPasswordForUser(SetPasswordForUserRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<SetPasswordForUserRequest, SetPasswordForUserCommand>(request, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>0.0.112</Version>
|
||||
@@ -12,14 +12,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.72.0">
|
||||
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>0.0.111</Version>
|
||||
@@ -12,14 +12,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.72.0">
|
||||
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>0.0.115</Version>
|
||||
@@ -12,14 +12,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.72.0">
|
||||
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -48,6 +48,18 @@ service UserContract
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc AdminGetJwtToken(AdminGetJwtTokenRequest) returns (AdminGetJwtTokenResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/AdminGetJwtToken"
|
||||
|
||||
};
|
||||
};
|
||||
rpc SetPasswordForUser(SetPasswordForUserRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/SetPasswordForUser"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
}
|
||||
message UpdateUserRequest
|
||||
{
|
||||
@@ -161,31 +173,47 @@ message VerifyOtpTokenResponse
|
||||
int32 remaining_attempts = 4;
|
||||
int32 remaining_seconds = 5;
|
||||
}
|
||||
|
||||
message PaginationState
|
||||
message AdminGetJwtTokenRequest
|
||||
{
|
||||
int32 page_number = 1;
|
||||
|
||||
int32 page_size = 2;
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
message MetaData
|
||||
message AdminGetJwtTokenResponse
|
||||
{
|
||||
int64 current_page = 1;
|
||||
|
||||
int64 total_page = 2;
|
||||
|
||||
int64 page_size = 3;
|
||||
|
||||
int64 total_count = 4;
|
||||
|
||||
bool has_previous = 5;
|
||||
|
||||
bool has_next = 6;
|
||||
string token = 1;
|
||||
}
|
||||
message DecimalValue
|
||||
message SetPasswordForUserRequest
|
||||
{
|
||||
|
||||
int64 units = 1;
|
||||
|
||||
sfixed32 nanos = 2;
|
||||
google.protobuf.StringValue current_password = 1;
|
||||
string new_password = 2;
|
||||
string confirm_password = 3;
|
||||
}
|
||||
|
||||
message PaginationState
|
||||
{
|
||||
int32 page_number = 1;
|
||||
|
||||
int32 page_size = 2;
|
||||
}
|
||||
message MetaData
|
||||
{
|
||||
int64 current_page = 1;
|
||||
|
||||
int64 total_page = 2;
|
||||
|
||||
int64 page_size = 3;
|
||||
|
||||
int64 total_count = 4;
|
||||
|
||||
bool has_previous = 5;
|
||||
|
||||
bool has_next = 6;
|
||||
}
|
||||
message DecimalValue
|
||||
{
|
||||
|
||||
int64 units = 1;
|
||||
|
||||
sfixed32 nanos = 2;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
namespace FrontOfficeMicroservice.Protobuf.Validator.User;
|
||||
|
||||
public class AdminGetJwtTokenRequestValidator : AbstractValidator<AdminGetJwtTokenRequest>
|
||||
{
|
||||
public AdminGetJwtTokenRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Username)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Password)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<AdminGetJwtTokenRequest>.CreateWithOptions((AdminGetJwtTokenRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
namespace FrontOfficeMicroservice.Protobuf.Validator.User;
|
||||
|
||||
public class SetPasswordForUserRequestValidator : AbstractValidator<SetPasswordForUserRequest>
|
||||
{
|
||||
public SetPasswordForUserRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.NewPassword)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.ConfirmPassword)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<SetPasswordForUserRequest>.CreateWithOptions((SetPasswordForUserRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>0.0.114</Version>
|
||||
@@ -12,14 +12,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.72.0">
|
||||
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>0.0.112</Version>
|
||||
@@ -12,14 +12,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.72.0">
|
||||
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user