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
Controller
Docker
Utils
Web
Phantom.Web
Phantom.Web.Bootstrap
Phantom.Web.Components
Phantom.Web.Services
Agents
Authentication
Authorization
Events
Instances
Rpc
Users
AuditLogManager.cs
RoleManager.cs
UserManager.cs
UserRoleManager.cs
ApplicationProperties.cs
Navigation.cs
Phantom.Web.Services.csproj
PhantomWebServices.cs
.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.1 KiB
C#

using System.Collections.Immutable;
using Phantom.Common.Data;
using Phantom.Common.Data.Web.AuditLog;
using Phantom.Common.Data.Web.Users;
using Phantom.Common.Messages.Web.ToController;
using Phantom.Web.Services.Authentication;
using Phantom.Web.Services.Rpc;
namespace Phantom.Web.Services.Users;
public sealed class AuditLogManager {
private readonly ControllerConnection controllerConnection;
public AuditLogManager(ControllerConnection controllerConnection) {
this.controllerConnection = controllerConnection;
}
public async Task<Result<ImmutableArray<AuditLogItem>, UserActionFailure>> GetMostRecentItems(AuthenticatedUser? authenticatedUser, int count, CancellationToken cancellationToken) {
if (authenticatedUser != null && authenticatedUser.Info.CheckPermission(Permission.ViewAudit)) {
var message = new GetAuditLogMessage(authenticatedUser.Token, count);
return await controllerConnection.Send<GetAuditLogMessage, Result<ImmutableArray<AuditLogItem>, UserActionFailure>>(message, cancellationToken);
}
else {
return UserActionFailure.NotAuthorized;
}
}
}