Added automatic token refresh feature and login page

This commit is contained in:
2024-07-14 21:25:36 +02:00
parent a164a3d282
commit 7cd412b168
16 changed files with 164 additions and 25 deletions

View File

@@ -5,11 +5,11 @@ using Microsoft.AspNetCore.Http;
namespace HopFrame.Security.Claims;
internal class TokenContextImplementor<TDbContext>(IHttpContextAccessor accessor, TDbContext context) : ITokenContext where TDbContext : HopDbContextBase {
public bool IsAuthenticated => accessor.HttpContext?.User.Identity?.IsAuthenticated == true;
public bool IsAuthenticated => !string.IsNullOrEmpty(accessor.HttpContext?.User.GetAccessTokenId());
public User User => context.Users
.SingleOrDefault(user => user.Id == accessor.HttpContext.User.GetUserId())?
.ToUserModel(context);
public Guid AccessToken => Guid.Parse(accessor.HttpContext?.User.GetAccessTokenId() ?? string.Empty);
public Guid AccessToken => Guid.Parse(accessor.HttpContext?.User.GetAccessTokenId() ?? Guid.Empty.ToString());
}