67 lines
2.7 KiB
Plaintext
67 lines
2.7 KiB
Plaintext
@using Microsoft.AspNetCore.Components.Authorization
|
|
<div class="auth-state-container">
|
|
<AuthorizeView>
|
|
<Authorized>
|
|
<div class="auth-indicator authenticated">
|
|
<div class="user-meta-stack">
|
|
<span class="meta-row-primary">@Name</span>
|
|
<span class="meta-row-secondary">@Email</span>
|
|
<span class="meta-row-secondary">@LoginTime</span>
|
|
</div>
|
|
</div>
|
|
</Authorized>
|
|
<NotAuthorized>
|
|
<div class="auth-indicator unauthenticated">
|
|
<svg class="security-lock-vector" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
<defs>
|
|
<filter id="amber-cyber-glow" x="-30%" y="-30%" width="160%" height="160%">
|
|
<feGaussianBlur stdDeviation="3.5" result="blur" />
|
|
<feComposite in="SourceGraphic" in2="blur" operator="over" />
|
|
</filter>
|
|
</defs>
|
|
|
|
<g class="lock-chassis" filter="url(#amber-cyber-glow)">
|
|
<path d="M 32,45 V 24 L 38,18 H 62 L 68,24 V 45" stroke="#ffd166" stroke-width="3.5" fill="none" stroke-linecap="square" stroke-linejoin="miter" />
|
|
|
|
<rect x="20" y="45" width="60" height="32" fill="#03090b" stroke="#ffd166" stroke-width="3.5" stroke-linejoin="miter" />
|
|
|
|
<polygon points="47,54 53,54 55,60 45,60" fill="#ffd166" />
|
|
<rect x="48.5" y="60" width="3" height="10" fill="#ffd166" />
|
|
</g>
|
|
</svg>
|
|
</div>
|
|
</NotAuthorized>
|
|
</AuthorizeView>
|
|
</div>
|
|
|
|
@code {
|
|
[CascadingParameter]
|
|
private Task<AuthenticationState>? AuthStateTask { get; set; }
|
|
|
|
private System.Security.Claims.ClaimsPrincipal? UserPrincipal;
|
|
|
|
private string? Name { get; set; }
|
|
private string? Email { get; set; }
|
|
private DateTime? LoginTime { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
if (AuthStateTask != null)
|
|
{
|
|
var authState = await AuthStateTask;
|
|
|
|
UserPrincipal = authState.User;
|
|
|
|
Name = UserPrincipal?.Identity?.Name;
|
|
Email = UserPrincipal?.FindFirst(System.Security.Claims.ClaimTypes.Email)?.Value;
|
|
|
|
var authTimeClaim = UserPrincipal?.FindFirst("auth_time")?.Value;
|
|
|
|
if (!string.IsNullOrEmpty(authTimeClaim) && long.TryParse(authTimeClaim, out long unixSeconds))
|
|
{
|
|
var dateTimeOffset = DateTimeOffset.FromUnixTimeSeconds(unixSeconds);
|
|
LoginTime = dateTimeOffset.LocalDateTime;
|
|
}
|
|
}
|
|
}
|
|
} |