mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Refactor user context handling with CurrentUserService
Introduced ICurrentUserService and its implementation to centralize retrieval of the current user's ID from claims. Updated FriendsController to use this service instead of direct claim access. Registered the service and IHttpContextAccessor in DI. Added integration tests for FriendsController. Moved UsernameValidator to Infrastructure/Validators.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using Govor.API.Services.AdminsStuff.Interfaces;
|
||||
using Govor.API.Services.Authentication.Interfaces;
|
||||
using Govor.Application.Infrastructure.Extensions;
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Application.Interfaces.AdminsStuff;
|
||||
using Govor.Application.Interfaces.Authentication;
|
||||
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||
using Govor.Application.Services;
|
||||
using Govor.Application.Validators;
|
||||
using Govor.Core.Infrastructure.Extensions;
|
||||
@@ -38,6 +40,9 @@ public static class ConfigurationProgramExtensions
|
||||
var env = sp.GetRequiredService<IWebHostEnvironment>();
|
||||
return new LocalStorageService(env.ContentRootPath);
|
||||
});
|
||||
|
||||
services.AddHttpContextAccessor(); // it's very important for CurrentUserService
|
||||
services.AddScoped<ICurrentUserService, CurrentUserService>();
|
||||
}
|
||||
|
||||
public static void AddRepositories(this IServiceCollection services)
|
||||
|
||||
Reference in New Issue
Block a user