From df12142c8113e2db9c848bfda20bd195673b7599 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 30 Apr 2017 16:01:48 +0000 Subject: [PATCH] Token logins. --- ShiftOS.Server/SaveManager.cs | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 41ca226..63aa2bf 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -198,6 +198,47 @@ namespace ShiftOS.Server } + [MudRequest("mud_token_login", typeof(string))] + public static void TokenLogin(string guid, string token) + { + foreach (var savefile in Directory.GetFiles("saves")) + { + try + { + var save = JsonConvert.DeserializeObject(ReadEncFile(savefile)); + + + if (save.UniteAuthToken==token) + { + if (save.ID == new Guid()) + { + save.ID = Guid.NewGuid(); + WriteEncFile(savefile, JsonConvert.SerializeObject(save)); + } + + + Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage + { + Name = "mud_savefile", + GUID = "server", + Contents = JsonConvert.SerializeObject(save) + })); + return; + } + } + catch { } + } + try + { + Program.server.DispatchTo(new Guid(guid), new NetObject("auth_failed", new ServerMessage + { + Name = "mud_login_denied", + GUID = "server" + })); + } + catch { } + } + [MudRequest("delete_save", typeof(ClientSave))] public static void DeleteSave(string guid, object contents) {