mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-04-21 10:53:59 +00:00
OOBE GUI版
This commit is contained in:
@@ -96,10 +96,7 @@ namespace CMLeonOS
|
||||
Console.BackgroundColor = ConsoleColor.Black;
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
|
||||
bool userDatExists = UserDatExists();
|
||||
string[] options = userDatExists
|
||||
? new[] { "CMLeonOS Shell", "CMLeonOS Desktop", "Reboot", "Shutdown" }
|
||||
: new[] { "CMLeonOS Shell", "Reboot", "Shutdown" };
|
||||
string[] options = new[] { "CMLeonOS Shell", "CMLeonOS Desktop", "Reboot", "Shutdown" };
|
||||
|
||||
int width = Console.WindowWidth;
|
||||
int height = Console.WindowHeight;
|
||||
@@ -152,14 +149,13 @@ namespace CMLeonOS
|
||||
|
||||
Console.CursorVisible = true;
|
||||
|
||||
bool userDatExists = UserDatExists();
|
||||
int optionIndex = 0;
|
||||
|
||||
if (selIdx == optionIndex++)
|
||||
{
|
||||
return BootMenuAction.NormalBoot;
|
||||
}
|
||||
if (userDatExists && selIdx == optionIndex++)
|
||||
if (selIdx == optionIndex++)
|
||||
{
|
||||
return BootMenuAction.GuiBoot;
|
||||
}
|
||||
@@ -179,7 +175,7 @@ namespace CMLeonOS
|
||||
|
||||
public static BootMenuAction Show()
|
||||
{
|
||||
if (Settings.SettingsManager.SkipToGui && UserDatExists())
|
||||
if (Settings.SettingsManager.SkipToGui)
|
||||
{
|
||||
return BootMenuAction.GuiBoot;
|
||||
}
|
||||
@@ -235,7 +231,7 @@ namespace CMLeonOS
|
||||
}
|
||||
}
|
||||
|
||||
int maxOptionIndex = UserDatExists() ? 3 : 2;
|
||||
int maxOptionIndex = 3;
|
||||
|
||||
if (selIdx < 0)
|
||||
{
|
||||
|
||||
@@ -827,6 +827,69 @@ namespace CMLeonOS
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateInitialAdminFromOobe(string username, string password, string hostname, out string error)
|
||||
{
|
||||
error = string.Empty;
|
||||
|
||||
username = (username ?? string.Empty).Trim();
|
||||
password = (password ?? string.Empty).Trim();
|
||||
hostname = (hostname ?? string.Empty).Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(username))
|
||||
{
|
||||
error = "Username cannot be empty.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ContainsInvalidChars(username))
|
||||
{
|
||||
error = "Username contains invalid characters.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
error = "Password cannot be empty.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(hostname))
|
||||
{
|
||||
error = "Hostname cannot be empty.";
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (User user in users)
|
||||
{
|
||||
if (user.Username.Equals(username, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
error = "Username already exists.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
User admin = new User
|
||||
{
|
||||
Username = username,
|
||||
Password = password,
|
||||
IsAdmin = true,
|
||||
Hostname = hostname
|
||||
};
|
||||
|
||||
users.Add(admin);
|
||||
SaveUsers();
|
||||
CreateUserFolder(username);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteUser(string username)
|
||||
{
|
||||
Console.WriteLine("====================================");
|
||||
|
||||
Reference in New Issue
Block a user