增加功能:只有管理员才可以使用user命令

This commit is contained in:
2026-02-06 21:20:28 +08:00
parent 96930adf91
commit 03309b1288
2 changed files with 14 additions and 0 deletions

View File

@@ -4,8 +4,21 @@ namespace CMLeonOS.Commands.User
{
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)
{
if (userSystem == null || userSystem.CurrentLoggedInUser == null || !userSystem.CurrentLoggedInUser.IsAdmin)
{
showError("Error: Only administrators can use the user command.");
return;
}
if (string.IsNullOrEmpty(args))
{
showError("Error: Please specify a user command");

View File

@@ -60,6 +60,7 @@ namespace CMLeonOS
Commands.AliasCommand.LoadAliases();
Commands.SettingsCommand.SetUserSystem(userSystem);
Commands.User.UserCommand.SetUserSystem(userSystem);
User currentUser = userSystem.CurrentLoggedInUser;
if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.Username))