Token logins.
This commit is contained in:
parent
baddaee3a8
commit
df12142c81
1 changed files with 41 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Reference in a new issue