-
Notifications
You must be signed in to change notification settings - Fork 0
/
WelcomeWizard.cs
80 lines (74 loc) · 2.34 KB
/
WelcomeWizard.cs
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
75
76
77
78
79
80
using MagmaMC.SharedLibrary;
using System.Text.RegularExpressions;
using VRCWMT.Models;
namespace VRCWMT;
public partial class WelcomeWizard : Form
{
public bool Canceled = true;
public WelcomeWizard()
{
InitializeComponent();
}
private void WelcomeWizard_Load(object sender, EventArgs e)
{
}
private void Click_CreateWorld_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Hide();
using AddWorld World = new AddWorld();
World.ShowDialog();
}
private void ContinueButton_Click(object sender, EventArgs e)
{
WarningText.Text = "";
ContinueButton.Enabled = false;
if (string.IsNullOrWhiteSpace(WorldID_Input.Text))
{
WarningText.Text = "Invalid WorldID";
ContinueButton.Enabled = true;
return;
}
new Thread(() =>
{
if (!Regex.Match(WorldID_Input.Text, @"^WRD_[0-9A-Z]{16}$").Success || API.GetWorld(WorldID_Input.Text) == null)
{
Invoke((MethodInvoker)delegate
{
WarningText.Text = "Invalid WorldID";
ContinueButton.Enabled = true;
});
return;
}
GithubUser githubUser = Github.GetUserAsync(Config.GithubAuth).GetResult();
SiteUser? User = API.GetUser(WorldID_Input.Text, githubUser.login);
if (User == null)
{
Invoke((MethodInvoker)delegate
{
WarningText.Text = "Invalid User";
ContinueButton.Enabled = true;
});
return;
}
if (!User.siteAdmin && !User.worldCreator && !User.siteOwner && !User.read)
{
Invoke((MethodInvoker)delegate
{
WarningText.Text = "Unauthorized";
ContinueButton.Enabled = true;
});
return;
}
Invoke((MethodInvoker)delegate
{
Config.WorldID = WorldID_Input.Text;
Config.WriteConfig();
Canceled = false;
Close();
});
}).Start();
}
private void WelcomeWizard_FormClosing(object sender, FormClosingEventArgs e)
{
}
}