mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-30 08:48:39 +00:00
Use permission level model for permissions
This is better. Because having 20 fucking columns for permissions is STUPID.
This commit is contained in:
parent
1b5e58dd80
commit
8301418085
16 changed files with 542 additions and 433 deletions
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Administration;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
|
@ -33,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.Banned = true;
|
||||
this.TargetedUser.PermissionLevel = PermissionLevel.Default;
|
||||
this.TargetedUser.BannedReason = reason;
|
||||
|
||||
// invalidate all currently active gametokens
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@page "/admin/users"
|
||||
@using LBPUnion.ProjectLighthouse.Administration
|
||||
@using LBPUnion.ProjectLighthouse.PlayerData.Profiles
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.AdminPanelUsersPage
|
||||
|
@ -14,17 +15,37 @@
|
|||
<div class="ui grid">
|
||||
@foreach (User user in Model.Users)
|
||||
{
|
||||
string color = "blue";
|
||||
string subtitle = "User";
|
||||
if (user.IsAdmin)
|
||||
string color;
|
||||
string subtitle;
|
||||
|
||||
switch (user.PermissionLevel)
|
||||
{
|
||||
color = "yellow";
|
||||
subtitle = "Admin";
|
||||
}
|
||||
if (user.Banned)
|
||||
{
|
||||
color = "red";
|
||||
subtitle = $"Banned user! Reason: {user.BannedReason}";
|
||||
// jank but works
|
||||
case PermissionLevel.Banned:
|
||||
{
|
||||
color = "red";
|
||||
subtitle = $"Banned user! Reason: {user.BannedReason}";
|
||||
break;
|
||||
}
|
||||
case PermissionLevel.Moderator:
|
||||
{
|
||||
color = "green";
|
||||
subtitle = "Moderator";
|
||||
break;
|
||||
}
|
||||
case PermissionLevel.Administrator:
|
||||
{
|
||||
color = "yellow";
|
||||
subtitle = "Admin";
|
||||
break;
|
||||
}
|
||||
case PermissionLevel.Default:
|
||||
default:
|
||||
{
|
||||
color = "blue";
|
||||
subtitle = "User";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subtitle += $" (id: {user.UserId})";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue