diff --git a/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml b/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml
index 9321859f..f9c242b3 100644
--- a/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml
+++ b/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml
@@ -8,6 +8,12 @@
Model.Title = "Admin Panel";
}
+
+
+ View Users
+
+
+
Commands
@foreach (ICommand command in MaintenanceHelper.Commands)
diff --git a/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml.cs b/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml.cs
index 8881f236..4df3a805 100644
--- a/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml.cs
+++ b/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml.cs
@@ -7,37 +7,35 @@ using LBPUnion.ProjectLighthouse.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.AspNetCore.Mvc;
-namespace LBPUnion.ProjectLighthouse.Pages.Admin
+namespace LBPUnion.ProjectLighthouse.Pages.Admin;
+
+public class AdminPanelPage : BaseLayout
{
- public class AdminPanelPage : BaseLayout
+ public List
Commands = MaintenanceHelper.Commands;
+ public AdminPanelPage(Database database) : base(database)
+ {}
+
+ public async Task OnGet([FromQuery] string? args, [FromQuery] string? command, [FromQuery] string? maintenanceJob)
{
+ User? user = this.Database.UserFromWebRequest(this.Request);
+ if (user == null) return this.Redirect("~/login");
+ if (!user.IsAdmin) return this.NotFound();
- public List Commands = MaintenanceHelper.Commands;
- public AdminPanelPage(Database database) : base(database)
- {}
-
- public async Task OnGet([FromQuery] string? args, [FromQuery] string? command, [FromQuery] string? maintenanceJob)
+ if (!string.IsNullOrEmpty(command))
{
- User? user = this.Database.UserFromWebRequest(this.Request);
- if (user == null) return this.Redirect("~/login");
- if (!user.IsAdmin) return this.NotFound();
-
- if (!string.IsNullOrEmpty(command))
- {
- args ??= "";
- args = command + " " + args;
- string[] split = args.Split(" ");
- await MaintenanceHelper.RunCommand(split);
- return this.Redirect("~/admin");
- }
-
- if (!string.IsNullOrEmpty(maintenanceJob))
- {
- await MaintenanceHelper.RunMaintenanceJob(maintenanceJob);
- return this.Redirect("~/admin");
- }
-
- return this.Page();
+ args ??= "";
+ args = command + " " + args;
+ string[] split = args.Split(" ");
+ await MaintenanceHelper.RunCommand(split);
+ return this.Redirect("~/admin");
}
+
+ if (!string.IsNullOrEmpty(maintenanceJob))
+ {
+ await MaintenanceHelper.RunMaintenanceJob(maintenanceJob);
+ return this.Redirect("~/admin");
+ }
+
+ return this.Page();
}
}
\ No newline at end of file
diff --git a/ProjectLighthouse/Pages/Admin/AdminPanelUsersPage.cshtml b/ProjectLighthouse/Pages/Admin/AdminPanelUsersPage.cshtml
new file mode 100644
index 00000000..92822597
--- /dev/null
+++ b/ProjectLighthouse/Pages/Admin/AdminPanelUsersPage.cshtml
@@ -0,0 +1,40 @@
+@page "/admin/users"
+@using LBPUnion.ProjectLighthouse.Types
+@model LBPUnion.ProjectLighthouse.Pages.Admin.AdminPanelUsersPage
+
+@{
+ Layout = "Layouts/BaseLayout";
+ Model.Title = "Users";
+}
+
+There are currently @Model.UserCount users registered to your instance.
+Note: Users are ordered by most-recent-first.
+
+
+ @foreach (User user in Model.Users)
+ {
+ string color = "blue";
+ string subtitle = "User";
+ if (user.IsAdmin)
+ {
+ color = "yellow";
+ subtitle = "Admin";
+ }
+ if (user.Banned)
+ {
+ color = "red";
+ subtitle = $"Banned user! Reason: {user.BannedReason}";
+ }
+
+ subtitle += $" (id: {user.UserId})";
+
+
+ }
+
\ No newline at end of file
diff --git a/ProjectLighthouse/Pages/Admin/AdminPanelUsersPage.cshtml.cs b/ProjectLighthouse/Pages/Admin/AdminPanelUsersPage.cshtml.cs
new file mode 100644
index 00000000..14b643eb
--- /dev/null
+++ b/ProjectLighthouse/Pages/Admin/AdminPanelUsersPage.cshtml.cs
@@ -0,0 +1,32 @@
+#nullable enable
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using LBPUnion.ProjectLighthouse.Pages.Layouts;
+using LBPUnion.ProjectLighthouse.Types;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+
+namespace LBPUnion.ProjectLighthouse.Pages.Admin;
+
+public class AdminPanelUsersPage : BaseLayout
+{
+ public AdminPanelUsersPage(Database database) : base(database)
+ {}
+
+ public int UserCount;
+
+ public List Users;
+
+ public async Task OnGet()
+ {
+ User? user = this.Database.UserFromWebRequest(this.Request);
+ if (user == null) return this.Redirect("~/login");
+ if (!user.IsAdmin) return this.NotFound();
+
+ this.Users = await this.Database.Users.OrderByDescending(u => u.UserId).ToListAsync();
+ this.UserCount = this.Users.Count;
+
+ return this.Page();
+ }
+}
\ No newline at end of file