29 lines
No EOL
795 B
Text
29 lines
No EOL
795 B
Text
@page "/RedeemToken/{code:guid}"
|
|
@using LANCommander.SDK.Models
|
|
@using Newtonsoft.Json
|
|
@using ZiggyCreatures.Caching.Fusion
|
|
@inject IFusionCache Cache
|
|
@inject IJSRuntime JSRuntime
|
|
|
|
Redeeming token...
|
|
|
|
@code {
|
|
[Parameter] public Guid Code { get; set; }
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
var token = await Cache.GetOrDefaultAsync<AuthToken>($"AuthToken/{Code}", null);
|
|
|
|
// Invalidate code, send token back to parent window, close
|
|
if (token != null)
|
|
{
|
|
await Cache.RemoveAsync($"AuthToken/{Code}");
|
|
|
|
await JSRuntime.InvokeVoidAsync("window.external.sendMessage", JsonConvert.SerializeObject(token));
|
|
}
|
|
}
|
|
}
|
|
|
|
} |