Convert to Blazor (#6)

Convert existing progress to Blazor on client and server
This commit was merged in pull request #6.
This commit is contained in:
2020-12-18 21:46:28 -05:00
committed by GitHub
parent 2f84821d11
commit e0b3fa8759
97 changed files with 2592 additions and 31063 deletions

View File

@@ -0,0 +1,36 @@
@page "/citizen/authorized"
@inject HttpClient http
@inject NavigationManager nav
@inject AppState state
<p>@message</p>
@code {
string message = "Logging you on with No Agenda Social...";
protected override async Task OnInitializedAsync()
{
// Exchange authorization code for a JWT
var query = QueryHelpers.ParseQuery(nav.ToAbsoluteUri(nav.Uri).Query);
if (query.TryGetValue("code", out var authCode))
{
var logOnResult = await ServerApi.LogOn(http, authCode);
if (logOnResult.IsOk)
{
var logOn = logOnResult.Ok;
state.User = new UserInfo(logOn.CitizenId, logOn.Name);
state.Jwt = logOn.Jwt;
nav.NavigateTo("/citizen/dashboard");
}
else
{
message = logOnResult.Error;
}
}
else
{
message = "Did not receive a token from No Agenda Social (perhaps you clicked \"Cancel\"?)";
}
}
}