feat(admin): restore Blazor WebAssembly architecture for admin pages with hybrid Server routing
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m40s
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m40s
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
namespace TaxBaik.Web.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Scoped in-memory token store for Blazor Server.
|
||||
/// SOLID: Single Responsibility - Token lifecycle management
|
||||
/// Avoids JS interop from DelegatingHandler (which runs on non-circuit thread)
|
||||
/// </summary>
|
||||
public interface ITokenStore
|
||||
{
|
||||
string? AccessToken { get; set; }
|
||||
string? RefreshToken { get; set; }
|
||||
long? TokenExpiryTicks { get; set; }
|
||||
|
||||
bool IsAccessTokenExpired();
|
||||
void Clear();
|
||||
}
|
||||
|
||||
public class TokenStore : ITokenStore
|
||||
{
|
||||
public string? AccessToken { get; set; }
|
||||
public string? RefreshToken { get; set; }
|
||||
public long? TokenExpiryTicks { get; set; }
|
||||
|
||||
public bool IsAccessTokenExpired()
|
||||
{
|
||||
if (TokenExpiryTicks == null)
|
||||
return true;
|
||||
|
||||
var expiryTime = new DateTime(TokenExpiryTicks.Value, DateTimeKind.Utc);
|
||||
return expiryTime <= DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
AccessToken = null;
|
||||
RefreshToken = null;
|
||||
TokenExpiryTicks = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user