Changed auth success ui. Switched to new interface service. Upgraded mooncore versions
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.6"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.6" PrivateAssets="all"/>
|
||||
<PackageReference Include="MoonCore" Version="1.6.6" />
|
||||
<PackageReference Include="MoonCore" Version="1.6.7" />
|
||||
<PackageReference Include="MoonCore.Blazor" Version="1.2.4" />
|
||||
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.0" />
|
||||
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.2" />
|
||||
<PackageReference Include="MoonCore.Blazor.Tailwind" Version="1.0.7" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
using MoonCore.Blazor.Extensions;
|
||||
@@ -9,6 +10,7 @@ using MoonCore.Exceptions;
|
||||
using MoonCore.Extensions;
|
||||
using MoonCore.Helpers;
|
||||
using MoonCore.Models;
|
||||
using MoonCore.PluginFramework.Extensions;
|
||||
using MoonCore.PluginFramework.Services;
|
||||
using Moonlight.Client.Implementations;
|
||||
using Moonlight.Client.Interfaces;
|
||||
@@ -103,16 +105,16 @@ builder.Services.AutoAddServices<Program>();
|
||||
FormComponentRepository.Set<string, StringComponent>();
|
||||
FormComponentRepository.Set<int, IntComponent>();
|
||||
|
||||
// Implementation service
|
||||
var implementationService = new ImplementationService();
|
||||
|
||||
implementationService.Register<ISidebarItemProvider, DefaultSidebarItemProvider>();
|
||||
|
||||
var authUiHandler = new AuthenticationUiHandler();
|
||||
implementationService.Register<IAppScreen>(authUiHandler);
|
||||
implementationService.Register<IAppLoader>(authUiHandler);
|
||||
|
||||
builder.Services.AddSingleton(implementationService);
|
||||
// Interface service
|
||||
builder.Services.AddPlugins(configuration =>
|
||||
{
|
||||
configuration.AddAssembly(Assembly.GetEntryAssembly()!);
|
||||
|
||||
configuration.AddInterface<IAppLoader>();
|
||||
configuration.AddInterface<IAppScreen>();
|
||||
|
||||
configuration.AddInterface<ISidebarItemProvider>();
|
||||
}, logger);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
@inject ImplementationService ImplementationService
|
||||
@inject IdentityService IdentityService
|
||||
@inject IServiceProvider ServiceProvider
|
||||
@inject ILogger<MainLayout> Logger
|
||||
@inject IAppLoader[] AppLoaders
|
||||
@inject IAppScreen[] AppScreens
|
||||
|
||||
@if (IsLoading)
|
||||
{
|
||||
@@ -98,8 +99,7 @@ else
|
||||
|
||||
private async Task RunLoaders()
|
||||
{
|
||||
var appLoaders = ImplementationService
|
||||
.Get<IAppLoader>()
|
||||
var appLoaders = AppLoaders
|
||||
.OrderBy(x => x.Priority);
|
||||
|
||||
foreach (var loader in appLoaders) //TODO: Measure performance of every loader?
|
||||
@@ -120,8 +120,7 @@ else
|
||||
{
|
||||
CurrentScreen = null;
|
||||
|
||||
var appScreens = ImplementationService
|
||||
.Get<IAppScreen>()
|
||||
var appScreens = AppScreens
|
||||
.OrderBy(x => x.Priority);
|
||||
|
||||
foreach (var screen in appScreens)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
@inject NavigationManager Navigation
|
||||
@inject IdentityService IdentityService
|
||||
@inject ImplementationService ImplementationService
|
||||
@inject ISidebarItemProvider[] SidebarItemProviders
|
||||
|
||||
@{
|
||||
var url = new Uri(Navigation.Uri);
|
||||
@@ -168,7 +168,7 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Items = ImplementationService.Get<ISidebarItemProvider>()
|
||||
Items = SidebarItemProviders
|
||||
.SelectMany(x => x.Get())
|
||||
.Where(x => x.Permission == null || (x.Permission != null && IdentityService.HasPermission(x.Permission)))
|
||||
.GroupBy(x => x.Group ?? "")
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
Moonlight.Client/wwwroot/svg/completed.svg
Normal file
1
Moonlight.Client/wwwroot/svg/completed.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user