diff options
| author | Michael <[email protected]> | 2017-07-13 08:40:47 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-07-13 08:40:47 -0400 |
| commit | e92af1bc7fe5cd5860206061f4ff261b3339cc51 (patch) | |
| tree | 14b571e2495731d7302b61c56d18ae5e4988587e /ShiftOS_TheReturn/TerminalBackend.cs | |
| parent | af01804c0fb4286f5975e973aec2b4eaf9752c08 (diff) | |
| download | shiftos_thereturn-e92af1bc7fe5cd5860206061f4ff261b3339cc51.tar.gz shiftos_thereturn-e92af1bc7fe5cd5860206061f4ff261b3339cc51.tar.bz2 shiftos_thereturn-e92af1bc7fe5cd5860206061f4ff261b3339cc51.zip | |
SidePanel system, system status, crapton of other neat things
Diffstat (limited to 'ShiftOS_TheReturn/TerminalBackend.cs')
| -rw-r--r-- | ShiftOS_TheReturn/TerminalBackend.cs | 96 |
1 files changed, 2 insertions, 94 deletions
diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index c8c6ba9..db6fde3 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -178,14 +178,6 @@ namespace ShiftOS.Engine public virtual void Invoke(Dictionary<string, object> args) { List<string> errors = new List<string>(); - bool requiresAuth = false; - if (!KernelWatchdog.IsSafe(this)) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - requiresAuth = true; - else - errors.Add("You can't run this command - you do not have permission."); - } if (errors.Count > 0) { foreach (var error in errors) @@ -194,33 +186,6 @@ namespace ShiftOS.Engine } return; } - if (requiresAuth) - { - Infobox.PromptText("Enter your password.", "This command requires you to have elevated permissions. Please enter your password to confirm this action.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - var uname = SaveSystem.CurrentUser.Username; - SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == "root"); - try - { - var h = CommandHandler; - h.Invoke(null, new[] { args }); - } - catch - { - var h = CommandHandler; - h.Invoke(null, null); - } - SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == uname); - } - else - { - Infobox.Show("Access denied.", "Incorrect password provided. The command will not run."); - } - }, true); - } - try { CommandHandler.Invoke(null, new[] { args }); @@ -512,7 +477,7 @@ namespace ShiftOS.Engine public static void PrintPrompt() { Console.WriteLine(); - if (SaveSystem.CurrentSave != null && CurrentUser != null) + if (SaveSystem.CurrentSave != null) { ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; ConsoleEx.Italic = false; @@ -521,7 +486,7 @@ namespace ShiftOS.Engine ConsoleEx.ForegroundColor = ConsoleColor.Magenta; ConsoleEx.Bold = true; - Console.Write(SaveSystem.CurrentUser.Username); + Console.Write(SaveSystem.CurrentSave.Username); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.Gray; Console.Write("@"); @@ -548,63 +513,6 @@ namespace ShiftOS.Engine } /// <summary> - /// Static constructor for <see cref="TerminalBackend"/>. - /// </summary> - static TerminalBackend() - { - ServerMessageReceived onMessageReceived = (msg) => - { - if (msg.Name == "trm_invokecommand") - { - string text3 = ""; - string text4 = msg.Contents; - - if (TerminalBackend.PrefixEnabled) - { - text3 = text4.Remove(0, $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); - } - IsForwardingConsoleWrites = true; - if (TerminalBackend.InStory == false) - { - TerminalBackend.InvokeCommand(text3, true); - } - if (TerminalBackend.PrefixEnabled) - { - Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - } - IsForwardingConsoleWrites = false; - } - else if (msg.Name == "pleasewrite") - { - Console.Write(msg.Contents); - } - else if (msg.Name == "handshake_from") - { - var a = JsonConvert.DeserializeObject<Dictionary<string, object>>(msg.Contents); - string uName = a["username"] as string; - string pass = a["password"] as string; - string sys = a["sysname"] as string; - string guid = msg.GUID; - if (SaveSystem.CurrentUser.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) - { - ForwardGUID = guid; - ServerManager.SendMessage("trm_handshake_accept", $@"{{ - guid: ""{ServerManager.thisGuid}"", - target: ""{guid}"" -}}"); - - IsForwardingConsoleWrites = true; - InvokeCommand("sos.status"); - Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - IsForwardingConsoleWrites = false; - } - } - }; - - ServerManager.MessageReceived += onMessageReceived; - } - - /// <summary> /// Gets whether the terminal backend is forwarding console write requests through RTS to a remote client. /// </summary> public static bool IsForwardingConsoleWrites { get; internal set; } |
