Current User

Accessing authenticated user information from RCommon

Configuration

// Add RCommon services
builder.Services.AddRCommon()
    .WithClaimsAndPrincipalAccessor();

Usage

public class MyService
{
    private readonly ICurrentUser _currentUser;

    public MyService(ICurrentUser currentUser)
    {
        _currentUser = currentUser;
    }
    
    public void Foo()
    {
        Guid? userId = _currentUser.Id;
    }
}

Last updated