Added app loaders and screen for the ui. Added identity service. Started auth screens
This commit is contained in:
27
Moonlight.Client/Implementations/AuthenticationUiHandler.cs
Normal file
27
Moonlight.Client/Implementations/AuthenticationUiHandler.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MoonCore.Blazor.Helpers;
|
||||
using Moonlight.Client.Interfaces;
|
||||
using Moonlight.Client.Services;
|
||||
using Moonlight.Client.UI.Screens;
|
||||
|
||||
namespace Moonlight.Client.Implementations;
|
||||
|
||||
public class AuthenticationUiHandler : IAppLoader, IAppScreen
|
||||
{
|
||||
public int Priority => 0;
|
||||
|
||||
public Task<bool> ShouldRender(IServiceProvider serviceProvider)
|
||||
{
|
||||
var identityService = serviceProvider.GetRequiredService<IdentityService>();
|
||||
|
||||
return Task.FromResult(identityService.IsLoggedIn);
|
||||
}
|
||||
|
||||
public RenderFragment Render() => ComponentHelper.FromType<AuthenticationScreen>();
|
||||
|
||||
public async Task Load(IServiceProvider serviceProvider)
|
||||
{
|
||||
var identityService = serviceProvider.GetRequiredService<IdentityService>();
|
||||
await identityService.Check();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user