mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
增加功能:设置只有管理员才可以设置
This commit is contained in:
@@ -5,6 +5,13 @@ namespace CMLeonOS.Commands
|
||||
{
|
||||
public static class SettingsCommand
|
||||
{
|
||||
private static UserSystem userSystem;
|
||||
|
||||
public static void SetUserSystem(UserSystem system)
|
||||
{
|
||||
userSystem = system;
|
||||
}
|
||||
|
||||
public static void ProcessSettings(string args)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(args))
|
||||
@@ -13,6 +20,12 @@ namespace CMLeonOS.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (userSystem == null || userSystem.CurrentLoggedInUser == null || !userSystem.CurrentLoggedInUser.IsAdmin)
|
||||
{
|
||||
Console.WriteLine("Error: Only administrators can change settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
string[] parts = args.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (parts.Length == 1)
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace CMLeonOS
|
||||
envManager = EnvironmentVariableManager.Instance;
|
||||
|
||||
Commands.AliasCommand.LoadAliases();
|
||||
Commands.SettingsCommand.SetUserSystem(userSystem);
|
||||
|
||||
User currentUser = userSystem.CurrentLoggedInUser;
|
||||
if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.Username))
|
||||
|
||||
Reference in New Issue
Block a user