Token logins.

This commit is contained in:
Michael VanOverbeek 2017-04-30 16:01:48 +00:00
parent baddaee3a8
commit df12142c81

View file

@ -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<Save>(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)
{