diff options
| author | AShifter <[email protected]> | 2017-05-01 13:37:48 -0600 |
|---|---|---|
| committer | AShifter <[email protected]> | 2017-05-01 13:37:48 -0600 |
| commit | d30eb35c9755cf430efa124a9a2576ab6b74c8da (patch) | |
| tree | bbf4c161697b390a96af01a36277c8dc4e52e1a0 /ShiftOS_TheReturn/UniteTestCommands.cs | |
| parent | b842c73b04fb92d9ecaf3d8fcc2df6157c2e8652 (diff) | |
| parent | 7532df70757ecbcaf735a5fc50eee282f555741a (diff) | |
| download | shiftos_thereturn-d30eb35c9755cf430efa124a9a2576ab6b74c8da.tar.gz shiftos_thereturn-d30eb35c9755cf430efa124a9a2576ab6b74c8da.tar.bz2 shiftos_thereturn-d30eb35c9755cf430efa124a9a2576ab6b74c8da.zip | |
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS_TheReturn/UniteTestCommands.cs')
| -rw-r--r-- | ShiftOS_TheReturn/UniteTestCommands.cs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/ShiftOS_TheReturn/UniteTestCommands.cs b/ShiftOS_TheReturn/UniteTestCommands.cs new file mode 100644 index 0000000..37ab1ee --- /dev/null +++ b/ShiftOS_TheReturn/UniteTestCommands.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + [Namespace("unite")] + public static class UniteTestCommands + { + [Command("login")] + [RequiresArgument("username")] + [RequiresArgument("password")] + public static bool LoginTest(Dictionary<string, object> args) + { + string u = args["username"].ToString(); + string p = args["password"].ToString(); + var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); + webrequest.Headers.Add("Authentication: Basic " + base64); + var response = webrequest.GetResponse(); + var str = response.GetResponseStream(); + var reader = new System.IO.StreamReader(str); + string result = reader.ReadToEnd(); + Console.WriteLine("Server returned: " + result); + reader.Close(); + str.Close(); + str.Dispose(); + response.Dispose(); + + return true; + } + + [Command("linklogin")] + [RequiresArgument("username")] + [RequiresArgument("password")] + public static bool LinkLogin(Dictionary<string, object> args) + { + string u = args["username"].ToString(); + string p = args["password"].ToString(); + var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); + webrequest.Headers.Add("Authentication: Basic " + base64); + var response = webrequest.GetResponse(); + var str = response.GetResponseStream(); + var reader = new System.IO.StreamReader(str); + string result = reader.ReadToEnd(); + //If we get this far, the token is OURS. :D + SaveSystem.CurrentSave.UniteAuthToken = result; + Console.WriteLine("Unite says \"Access Granted!\""); + SaveSystem.SaveGame(); + reader.Close(); + str.Close(); + str.Dispose(); + response.Dispose(); + + return true; + } + + + } +} |
