Changed auth success ui. Switched to new interface service. Upgraded mooncore versions

This commit is contained in:
Masu Baumgartner
2024-10-27 20:49:06 +01:00
parent 7239182e83
commit c15f18108d
9 changed files with 73 additions and 60 deletions

View File

@@ -12,6 +12,8 @@
@inject HttpClient HttpClient
@inject LocalStorageService LocalStorageService
@inject ILogger<AuthenticationScreen> Logger
@if (Code == null)
{
<div class="h-full w-full min-h-[100dvh] flex items-center justify-center px-5 md:px-0">
@@ -53,14 +55,10 @@ else
@if (IsHandlingDone)
{
<div class="sm:mx-auto sm:w-full sm:max-w-sm mb-5">
<img class="mx-auto h-16 w-auto" src="/logolong.webp" alt="Moonlight">
<h2 class="mt-6 text-center text-2xl font-bold leading-9 tracking-tight text-gray-100">Login to access your account</h2>
</div>
<div class="flex justify-center">
<p class="mt-3 text-center text-md text-gray-400">
<img class="mx-auto w-auto h-32" src="/svg/completed.svg" alt="Completed illustration">
<h2 class="mt-6 text-center text-2xl font-semibold leading-9 tracking-tight text-gray-100">
Login successful. You can close this window now
</p>
</h2>
</div>
}
else
@@ -91,25 +89,35 @@ else
if (Code == null)
return;
var authHandleData = await HttpApiClient.PostJson<OAuth2HandleResponse>("api/auth", new OAuth2HandleRequest()
{
Code = Code
});
await LocalStorageService.SetString("AccessToken", authHandleData.AccessToken);
await LocalStorageService.SetString("RefreshToken", authHandleData.RefreshToken);
await LocalStorageService.Set("ExpiresAt", authHandleData.ExpiresAt);
try
{
await WindowService.Close();
}
finally
{
var authHandleData = await HttpApiClient.PostJson<OAuth2HandleResponse>("api/auth", new OAuth2HandleRequest()
{
Code = Code
});
// Save the auth handle data
await LocalStorageService.SetString("AccessToken", authHandleData.AccessToken);
await LocalStorageService.SetString("RefreshToken", authHandleData.RefreshToken);
await LocalStorageService.Set("ExpiresAt", authHandleData.ExpiresAt);
// Update UI
IsHandlingDone = true;
await InvokeAsync(StateHasChanged);
await Task.Delay(TimeSpan.FromSeconds(2));
Navigation.NavigateTo("/", true);
try
{
await WindowService.Close();
}
finally
{
Navigation.NavigateTo("/", true);
}
}
catch (Exception e)
{
Logger.LogError("An unhandled error occured while handling oauth2 code: {e}", e);
}
}