mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
增加功能:只有管理员才可以使用user命令
This commit is contained in:
@@ -4,8 +4,21 @@ namespace CMLeonOS.Commands.User
|
|||||||
{
|
{
|
||||||
public static class UserCommand
|
public static class UserCommand
|
||||||
{
|
{
|
||||||
|
private static CMLeonOS.UserSystem userSystem;
|
||||||
|
|
||||||
|
public static void SetUserSystem(CMLeonOS.UserSystem system)
|
||||||
|
{
|
||||||
|
userSystem = system;
|
||||||
|
}
|
||||||
|
|
||||||
public static void ProcessUserCommand(string args, CMLeonOS.UserSystem userSystem, Action<string> showError)
|
public static void ProcessUserCommand(string args, CMLeonOS.UserSystem userSystem, Action<string> showError)
|
||||||
{
|
{
|
||||||
|
if (userSystem == null || userSystem.CurrentLoggedInUser == null || !userSystem.CurrentLoggedInUser.IsAdmin)
|
||||||
|
{
|
||||||
|
showError("Error: Only administrators can use the user command.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(args))
|
if (string.IsNullOrEmpty(args))
|
||||||
{
|
{
|
||||||
showError("Error: Please specify a user command");
|
showError("Error: Please specify a user command");
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
Commands.AliasCommand.LoadAliases();
|
Commands.AliasCommand.LoadAliases();
|
||||||
Commands.SettingsCommand.SetUserSystem(userSystem);
|
Commands.SettingsCommand.SetUserSystem(userSystem);
|
||||||
|
Commands.User.UserCommand.SetUserSystem(userSystem);
|
||||||
|
|
||||||
User currentUser = userSystem.CurrentLoggedInUser;
|
User currentUser = userSystem.CurrentLoggedInUser;
|
||||||
if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.Username))
|
if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.Username))
|
||||||
|
|||||||
Reference in New Issue
Block a user