diff --git a/.gitignore b/.gitignore index 2783648d..900a9589 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ png/ /ProjectLighthouse/logs/* lighthouse.config.json lighthouse.yml +lighthouse.yml.configme gitBranch.txt gitVersion.txt gitRemotes.txt diff --git a/.idea/.idea.ProjectLighthouse/.idea/indexLayout.xml b/.idea/.idea.ProjectLighthouse/.idea/indexLayout.xml index e9bcd75e..ea6692c6 100644 --- a/.idea/.idea.ProjectLighthouse/.idea/indexLayout.xml +++ b/.idea/.idea.ProjectLighthouse/.idea/indexLayout.xml @@ -10,6 +10,7 @@ CONTRIBUTING.md DatabaseMigrations LICENSE + ProjectLighthouse.Localization ProjectLighthouse.sln.DotSettings ProjectLighthouse.sln.DotSettings.user README.md diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs index 72d8023d..c6a7da4c 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs @@ -101,4 +101,26 @@ public class AdminUserController : ControllerBase return this.Redirect($"/user/{targetedUser.UserId}"); } + + [HttpPost("setPermissionLevel")] + public async Task SetUserPermissionLevel([FromRoute] int id, [FromForm] PermissionLevel role) + { + User? user = this.database.UserFromWebRequest(this.Request); + if (user == null || !user.IsAdmin) return this.NotFound(); + + User? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id); + if (targetedUser == null) return this.NotFound(); + + if (role != PermissionLevel.Banned) + { + targetedUser.PermissionLevel = role; + await this.database.SaveChangesAsync(); + } + else + { + return this.Redirect($"/admin/user/{id}/ban"); + } + + return this.Redirect("/admin/users"); + } } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminBanUserPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminBanUserPage.cshtml.cs index cda7b9ad..5a7c99c3 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminBanUserPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminBanUserPage.cshtml.cs @@ -34,7 +34,7 @@ public class AdminBanUserPage : BaseLayout this.TargetedUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == id); if (this.TargetedUser == null) return this.NotFound(); - this.TargetedUser.PermissionLevel = PermissionLevel.Default; + this.TargetedUser.PermissionLevel = PermissionLevel.Banned; this.TargetedUser.BannedReason = reason; // invalidate all currently active gametokens diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml index 2c0d1515..dab80756 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml @@ -10,7 +10,7 @@ }

There are currently @Model.UserCount users registered to your instance.

-

Note: Users are ordered by most-recent-first.

+

Note: Users are ordered by their permissions, then by most-recent-first.

@foreach (User user in Model.Users) @@ -56,6 +56,19 @@ @user.Username

@subtitle

+
+
+ + +
+
} diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml.cs index 1bde19da..5f0e61bd 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml.cs @@ -21,7 +21,11 @@ public class AdminPanelUsersPage : BaseLayout 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.Users = await this.Database.Users + .OrderByDescending(u => u.PermissionLevel) + .ThenByDescending(u => u.UserId) + .ToListAsync(); + this.UserCount = this.Users.Count; return this.Page();