Updated MoonCore dependencies. Switched to asp.net core native authentication scheme abstractions. Updated claim usage in frontend
This commit is contained in:
19
Moonlight.Client/Implementations/LogErrorFilter.cs
Normal file
19
Moonlight.Client/Implementations/LogErrorFilter.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using MoonCore.Blazor.FlyonUi.Exceptions;
|
||||
|
||||
namespace Moonlight.Client.Implementations;
|
||||
|
||||
public class LogErrorFilter : IGlobalErrorFilter
|
||||
{
|
||||
private readonly ILogger<LogErrorFilter> Logger;
|
||||
|
||||
public LogErrorFilter(ILogger<LogErrorFilter> logger)
|
||||
{
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
public Task<bool> HandleException(Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Global error processed");
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MoonCore.Blazor.FlyonUi.Exceptions;
|
||||
using MoonCore.Exceptions;
|
||||
|
||||
namespace Moonlight.Client.Implementations;
|
||||
|
||||
public class UnauthenticatedErrorFilter : IGlobalErrorFilter
|
||||
{
|
||||
private readonly NavigationManager Navigation;
|
||||
|
||||
public UnauthenticatedErrorFilter(NavigationManager navigation)
|
||||
{
|
||||
Navigation = navigation;
|
||||
}
|
||||
|
||||
public Task<bool> HandleException(Exception ex)
|
||||
{
|
||||
if (ex is not HttpApiException { Status: 401 })
|
||||
return Task.FromResult(false);
|
||||
|
||||
Navigation.NavigateTo("/api/auth/logout", true);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user