Adjusting to use new extension methods to configure and handle token auth and oauth2

This commit is contained in:
Masu-Baumgartner
2024-11-06 16:46:24 +01:00
parent 288b0c8d97
commit f2d653563c
8 changed files with 63 additions and 330 deletions

View File

@@ -35,16 +35,12 @@ else
<main class="py-10">
<div class="px-4 sm:px-6 lg:px-8">
<ErrorHandler CustomHandler="HandleException">
<TestyHmm>
<PermissionHandler CheckFunction="CheckPermission">
<CascadingValue Value="this" IsFixed="true">
@Body
</CascadingValue>
</PermissionHandler>
</TestyHmm>
<ErrorHandler>
<PermissionHandler CheckFunction="CheckPermission">
<CascadingValue Value="this" IsFixed="true">
@Body
</CascadingValue>
</PermissionHandler>
</ErrorHandler>
</div>
</main>
@@ -110,6 +106,10 @@ else
Logger.LogDebug("Running application loader '{name}'", loader.GetType().Name);
await loader.Load(ServiceProvider);
}
catch (HttpApiException)
{
throw;
}
catch (Exception e)
{
Logger.LogCritical("An app loader threw an unhandled exception: {e}", e);
@@ -139,15 +139,4 @@ else
}
private bool CheckPermission(string permission) => IdentityService.HasPermission(permission);
private Task<bool> HandleException(Exception exception, ErrorHandler handler)
{
if (exception is HttpApiException httpApiException && httpApiException.Status == 401)
{
Task.Run(Load);
return Task.FromResult(true);
}
return Task.FromResult(false);
}
}