initial commit from an older template

This commit is contained in:
2025-09-20 22:33:35 +03:00
commit b6778046c2
134 changed files with 6657 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
using GamificationService.Models;
namespace GamificationService.Services.CurrentUsers;
public class CurrentUserService : ICurrentUserService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ILogger<ICurrentUserService> _logger;
public CurrentUserService(IHttpContextAccessor httpContextAccessor, ILogger<ICurrentUserService> logger)
{
_httpContextAccessor = httpContextAccessor;
_logger = logger;
}
public UserSession GetCurrentUser()
{
UserSession currentUser = new UserSession
{
IsAuthenticated = _httpContextAccessor.HttpContext.User.Identity != null && _httpContextAccessor.HttpContext.User.Identity.IsAuthenticated,
Login = _httpContextAccessor.HttpContext.User.Identity.Name
};
_logger.LogDebug($"Current user extracted: {currentUser.Login}");
return currentUser;
}
}