mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-19 00:42:09 +00:00
Add ability to change user's permissions from admin panel user list
This commit is contained in:
parent
ff12f5f7d5
commit
1037a6eddb
6 changed files with 44 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
}
|
||||
|
||||
<p>There are currently @Model.UserCount users registered to your instance.</p>
|
||||
<p><b>Note:</b> Users are ordered by most-recent-first.</p>
|
||||
<p><b>Note:</b> Users are ordered by their permissions, then by most-recent-first.</p>
|
||||
|
||||
<div class="ui grid">
|
||||
@foreach (User user in Model.Users)
|
||||
|
@ -56,6 +56,19 @@
|
|||
<a href="/user/@user.UserId">@user.Username</a>
|
||||
</h2>
|
||||
<h3>@subtitle</h3>
|
||||
<form method="post" action="/admin/user/@user.UserId/setPermissionLevel">
|
||||
<div class="ui right action input">
|
||||
<select name="role" class="ui selection dropdown">
|
||||
@foreach (PermissionLevel level in Enum.GetValues<PermissionLevel>())
|
||||
{
|
||||
string selected = level == user.PermissionLevel ? " selected" : "";
|
||||
|
||||
<option value="@((int)level)"@selected>@level.ToString()</option>
|
||||
}
|
||||
</select>
|
||||
<input type="submit" class="ui green button" value="Apply"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue