- Renamed all directories (TrueCV.* -> RealCV.*) - Renamed all project files (.csproj) - Renamed solution file (TrueCV.sln -> RealCV.sln) - Updated all namespaces in C# and Razor files - Updated project references - Updated CSS variable names 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
29 lines
882 B
C#
29 lines
882 B
C#
using System.Security.Claims;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using RealCV.Application.Interfaces;
|
|
|
|
namespace RealCV.Infrastructure.Services;
|
|
|
|
public sealed class UserContextService : IUserContextService
|
|
{
|
|
private readonly AuthenticationStateProvider _authenticationStateProvider;
|
|
|
|
public UserContextService(AuthenticationStateProvider authenticationStateProvider)
|
|
{
|
|
_authenticationStateProvider = authenticationStateProvider;
|
|
}
|
|
|
|
public async Task<Guid?> GetCurrentUserIdAsync()
|
|
{
|
|
var authState = await _authenticationStateProvider.GetAuthenticationStateAsync();
|
|
var userIdClaim = authState.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
|
|
if (string.IsNullOrEmpty(userIdClaim) || !Guid.TryParse(userIdClaim, out var userId))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return userId;
|
|
}
|
|
}
|