From 03309b12887aee443416222b39d7b0ed628b4963 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Fri, 6 Feb 2026 21:20:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E5=8F=AA=E6=9C=89=E7=AE=A1=E7=90=86=E5=91=98=E6=89=8D=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=E7=94=A8user=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/Commands/User/UserCommand.cs | 13 +++++++++++++ shell/Shell.cs | 1 + 2 files changed, 14 insertions(+) diff --git a/shell/Commands/User/UserCommand.cs b/shell/Commands/User/UserCommand.cs index 311c266..060842f 100644 --- a/shell/Commands/User/UserCommand.cs +++ b/shell/Commands/User/UserCommand.cs @@ -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 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"); diff --git a/shell/Shell.cs b/shell/Shell.cs index dada5bb..d587d33 100644 --- a/shell/Shell.cs +++ b/shell/Shell.cs @@ -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))