You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Common/Common/Security/Identity/IdentityService.cs

18 lines
528 B

2 years ago
using Connected.Security.Identity;
using Microsoft.AspNetCore.Http;
namespace Common.Security.Identity;
internal class IdentityService : IIdentityService
{
public IdentityService(IHttpContextAccessor contextAccessor)
{
HttpContext = contextAccessor.HttpContext;
}
private HttpContext? HttpContext { get; }
public IUser? CurrentUser => Identity?.User;
public bool IsAuthenticated => Identity is not null && Identity.IsAuthenticated;
private UserIdentity? Identity => HttpContext?.User?.Identity as UserIdentity;
}