1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2025-08-16 21:31:45 +02:00
Files
.config
.run
.workdir
Agent
Common
Docker
Server
Phantom.Server
Phantom.Server.Database
Phantom.Server.Database.Postgres
Phantom.Server.Minecraft
Phantom.Server.Rpc
Phantom.Server.Services
Phantom.Server.Web
Base
LoginEvents.cs
Navigation.cs
PhantomComponent.cs
Layout
Pages
Shared
Utils
wwwroot
App.razor
Configuration.cs
Launcher.cs
Phantom.Server.Web.csproj
_Imports.razor
appsettings.json
Phantom.Server.Web.Bootstrap
Phantom.Server.Web.Components
Phantom.Server.Web.Identity
Utils
.dockerignore
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
Directory.Build.props
Directory.Build.targets
Dockerfile
LICENSE
Packages.props
PhantomPanel.sln
README.md
global.json

28 lines
1.0 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Phantom.Common.Logging;
using Phantom.Server.Web.Identity.Authorization;
using Phantom.Server.Web.Identity.Data;
using ILogger = Serilog.ILogger;
namespace Phantom.Server.Web.Base;
public abstract class PhantomComponent : ComponentBase {
private static readonly ILogger Logger = PhantomLogger.Create<PhantomComponent>();
[CascadingParameter]
public Task<AuthenticationState> AuthenticationStateTask { get; set; } = null!;
[Inject]
public PermissionManager PermissionManager { get; set; } = null!;
protected async Task<bool> CheckPermission(Permission permission) {
var authenticationState = await AuthenticationStateTask;
return PermissionManager.CheckPermission(authenticationState.User, permission, refreshCache: true);
}
protected void InvokeAsyncChecked(Func<Task> task) {
InvokeAsync(task).ContinueWith(static t => Logger.Error(t.Exception, "Caught exception in async task."), TaskContinuationOptions.OnlyOnFaulted);
}
}