-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SporeServer: improve /Moderation/Management/Users
- Loading branch information
1 parent
ae0931f
commit 5951091
Showing
2 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* SporeServer - https://github.com/Rosalie241/SporeServer | ||
* Copyright (C) 2021 Rosalie Wanders <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License version 3. | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
@@ -25,6 +34,10 @@ public UsersModel(UserManager<SporeServerUser> userManager, IUserSubscriptionMan | |
_assetManager = assetManager; | ||
} | ||
|
||
/// <summary> | ||
/// Current User | ||
/// </summary> | ||
public SporeServerUser CurrentUser { get; set; } | ||
/// <summary> | ||
/// Search Results | ||
/// </summary> | ||
|
@@ -38,10 +51,20 @@ public UsersModel(UserManager<SporeServerUser> userManager, IUserSubscriptionMan | |
/// </summary> | ||
public bool Searched { get; set; } | ||
|
||
/// <summary> | ||
/// Whether user is in specified role or not | ||
/// </summary> | ||
public async Task<bool> IsUserInRoleAsync(SporeServerUser user, string role) | ||
{ | ||
return (await _userManager.GetRolesAsync(user)).Contains(role); | ||
} | ||
|
||
public async Task<IActionResult> OnGet() | ||
{ | ||
SearchString = Request.Query["searchText"]; | ||
|
||
CurrentUser = await _userManager.GetUserAsync(User); | ||
|
||
if (String.IsNullOrEmpty(SearchString)) | ||
{ | ||
Users = await _userManager.Users | ||
|