blob: 37ab1ee05f42d57f447426f8b6fc7d09df045c4a (
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
|
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;
}
}
}
|