Merge branch 'main' into stage

This commit is contained in:
masoodafar-web
2025-11-14 04:43:35 +03:30
34 changed files with 1954 additions and 887 deletions

File diff suppressed because it is too large Load Diff

13
src/.idea/.idea.FrontOffice.BFF/.idea/.gitignore generated vendored Normal file
View 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

View File

@@ -0,0 +1 @@
FrontOffice.BFF

View 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>

View 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>

View 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>

View 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>

View 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>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View 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>

View File

@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
<PackageReference Include="Mapster" Version="7.3.0" /> <PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.0" /> <PackageReference Include="Mapster.DependencyInjection" Version="1.0.1" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" /> <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FrontOffice.BFF.Domain\FrontOffice.BFF.Domain.csproj" /> <ProjectReference Include="..\FrontOffice.BFF.Domain\FrontOffice.BFF.Domain.csproj" />

View File

@@ -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; }
}

View File

@@ -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();
}
}

View File

@@ -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);
};
}

View File

@@ -1,6 +1,7 @@
using CMSMicroservice.Protobuf.Protos.User; using CMSMicroservice.Protobuf.Protos.User;
namespace FrontOffice.BFF.Application.UserCQ.Commands.UpdateUser; namespace FrontOffice.BFF.Application.UserCQ.Commands.UpdateUser;
public class UpdateUserCommandHandler : IRequestHandler<UpdateUserCommand, Unit> public class UpdateUserCommandHandler : IRequestHandler<UpdateUserCommand, Unit>
{ {
private readonly IApplicationContractContext _context; private readonly IApplicationContractContext _context;
@@ -12,7 +13,56 @@ public class UpdateUserCommandHandler : IRequestHandler<UpdateUserCommand, Unit>
public async Task<Unit> Handle(UpdateUserCommand request, CancellationToken cancellationToken) 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; return Unit.Value;
} }
} }

View File

@@ -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; }
}

View File

@@ -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>();
}
}

View File

@@ -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);
};
}

View File

@@ -0,0 +1,7 @@
namespace FrontOffice.BFF.Application.UserCQ.Queries.AdminGetJwtToken;
public class AdminGetJwtTokenResponseDto
{
//توکن
public string Token { get; set; }
}

View File

@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Afrino.PYMSMicroservice.Protobuf" Version="0.0.11" /> <PackageReference Include="Afrino.PYMSMicroservice.Protobuf" Version="0.0.11" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.117" /> <PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.118" />
<PackageReference Include="Google.Protobuf" Version="3.23.3" /> <PackageReference Include="Google.Protobuf" Version="3.33.0" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.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> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@@ -31,8 +31,8 @@ public static class ConfigureServices
jwtBearerOptions.RequireHttpsMetadata = false; jwtBearerOptions.RequireHttpsMetadata = false;
jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters
{ {
ValidateIssuer = true, ValidateIssuer = false,//todo change to true in production
ValidateAudience = true, ValidateAudience = false,//todo change to true in production
ValidateLifetime = true, ValidateLifetime = true,
ValidateIssuerSigningKey = true, ValidateIssuerSigningKey = true,
ValidIssuer = configuration["JwtIssuer"], ValidIssuer = configuration["JwtIssuer"],

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" /> <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" /> <PackageReference Include="KavenegarDotNetCore" Version="1.0.7" />
</ItemGroup> </ItemGroup>

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..\..</DockerfileContext> <DockerfileContext>..\..\..</DockerfileContext>
@@ -10,11 +10,11 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.54.0" /> <PackageReference Include="Grpc.AspNetCore" Version="2.54.0" />
<PackageReference Include="Grpc.AspNetCore.Web" 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.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
<PackageReference Include="Microsoft.AspNetCore.Grpc.Swagger" Version="0.3.8" /> <PackageReference Include="Microsoft.AspNetCore.Grpc.Swagger" Version="0.9.11" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="6.3.0" /> <PackageReference Include="Serilog.Sinks.MSSqlServer" Version="9.0.2" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" /> <PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,4 +1,3 @@
using FrontOffice.BFF.User.Protobuf.Protos.User;
using FrontOffice.BFF.WebApi.Common.Services; using FrontOffice.BFF.WebApi.Common.Services;
using FrontOffice.BFF.Application.UserCQ.Commands.UpdateUser; using FrontOffice.BFF.Application.UserCQ.Commands.UpdateUser;
using FrontOffice.BFF.Application.UserCQ.Commands.DeleteUser; 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.Queries.GetAllUserByFilter;
using FrontOffice.BFF.Application.UserCQ.Commands.CreateNewOtpToken; using FrontOffice.BFF.Application.UserCQ.Commands.CreateNewOtpToken;
using FrontOffice.BFF.Application.UserCQ.Commands.VerifyOtpToken; 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; namespace FrontOffice.BFF.WebApi.Services;
public class UserService : UserContract.UserContractBase public class UserService : UserContract.UserContractBase
{ {
@@ -15,6 +18,7 @@ public class UserService : UserContract.UserContractBase
{ {
_dispatchRequestToCQRS = dispatchRequestToCQRS; _dispatchRequestToCQRS = dispatchRequestToCQRS;
} }
[Authorize(Roles = "user")]
public override async Task<Empty> UpdateUser(UpdateUserRequest request, ServerCallContext context) public override async Task<Empty> UpdateUser(UpdateUserRequest request, ServerCallContext context)
{ {
return await _dispatchRequestToCQRS.Handle<UpdateUserRequest, UpdateUserCommand>(request, 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); 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);
}
} }

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>0.0.112</Version> <Version>0.0.112</Version>
@@ -12,14 +12,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" /> <PackageReference Include="Google.Protobuf" Version="3.33.0" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" /> <PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0"> <PackageReference Include="Grpc.Tools" Version="2.76.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" /> <PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>0.0.111</Version> <Version>0.0.111</Version>
@@ -12,14 +12,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" /> <PackageReference Include="Google.Protobuf" Version="3.33.0" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" /> <PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0"> <PackageReference Include="Grpc.Tools" Version="2.76.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" /> <PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>0.0.115</Version> <Version>0.0.115</Version>
@@ -12,14 +12,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" /> <PackageReference Include="Google.Protobuf" Version="3.33.0" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" /> <PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0"> <PackageReference Include="Grpc.Tools" Version="2.76.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" /> <PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -48,6 +48,18 @@ service UserContract
body: "*" 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 message UpdateUserRequest
{ {
@@ -161,15 +173,30 @@ message VerifyOtpTokenResponse
int32 remaining_attempts = 4; int32 remaining_attempts = 4;
int32 remaining_seconds = 5; int32 remaining_seconds = 5;
} }
message AdminGetJwtTokenRequest
message PaginationState
{ {
string username = 1;
string password = 2;
}
message AdminGetJwtTokenResponse
{
string token = 1;
}
message SetPasswordForUserRequest
{
google.protobuf.StringValue current_password = 1;
string new_password = 2;
string confirm_password = 3;
}
message PaginationState
{
int32 page_number = 1; int32 page_number = 1;
int32 page_size = 2; int32 page_size = 2;
} }
message MetaData message MetaData
{ {
int64 current_page = 1; int64 current_page = 1;
int64 total_page = 2; int64 total_page = 2;
@@ -181,11 +208,12 @@ message MetaData
bool has_previous = 5; bool has_previous = 5;
bool has_next = 6; bool has_next = 6;
} }
message DecimalValue message DecimalValue
{ {
int64 units = 1; int64 units = 1;
sfixed32 nanos = 2; sfixed32 nanos = 2;
} }

View File

@@ -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);
};
}

View File

@@ -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);
};
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>0.0.114</Version> <Version>0.0.114</Version>
@@ -12,14 +12,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" /> <PackageReference Include="Google.Protobuf" Version="3.33.0" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" /> <PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0"> <PackageReference Include="Grpc.Tools" Version="2.76.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" /> <PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>0.0.112</Version> <Version>0.0.112</Version>
@@ -12,14 +12,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" /> <PackageReference Include="Google.Protobuf" Version="3.33.0" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" /> <PackageReference Include="Grpc.Core.Api" Version="2.71.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0"> <PackageReference Include="Grpc.Tools" Version="2.76.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.0" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" /> <PackageReference Include="Google.Api.CommonProtos" Version="2.17.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>