blob: 7a83e441ba1ac1085f2db1d01ef98c4ee96c8288 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
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("setdisplayname")]
[RequiresArgument("name")]
public static bool SetDisplayName(Dictionary<string, object> args)
{
string dname = args["name"].ToString();
var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken);
unite.SetDisplayName(dname);
return true;
}
[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;
}
}
}
|