Skip to content

Commit 27fc7c3

Browse files
committed
Implement Index Saving for ACM
Added: - Account Manager Index can now be set after a successful login on a server
1 parent c2e9aff commit 27fc7c3

File tree

10 files changed

+434
-372
lines changed

10 files changed

+434
-372
lines changed

SBRW.Launcher.Net/App/UI_Forms/Main_Screen/Screen_Main_Events.cs

Lines changed: 60 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
using System.IO;
3030
using System.Net;
3131
using System.Windows.Forms;
32+
using System.Linq;
33+
using SBRW.Launcher.Core.Extension.List_;
34+
using SBRW.Launcher.RunTime.LauncherCore.Client.Auth.JSON;
3235
#endregion
3336

3437
namespace SBRW.Launcher.App.UI_Forms.Main_Screen
@@ -142,19 +145,20 @@ private void LoginButton_Click(object? sender, EventArgs? e)
142145

143146
Tokens.Clear();
144147

145-
string Email;
146-
string Password;
147-
148148
Tokens.IPAddress = Launcher_Value.Launcher_Select_Server_Data.IPAddress;
149149
Tokens.ServerName = ServerListUpdater.ServerName("Login");
150150

151+
AuthenticationGeneration Live_Information = default;
152+
151153
if (Save_Settings.Account_Manager())
152154
{
153155
if (ComboBox_Accounts.SelectedItem != default)
154156
{
155157
Button_Login.Text = "Decrypting".ToUpper();
156-
Email = ((Json_List_Account)ComboBox_Accounts.SelectedItem).Email.Decrypt_AES();
157-
Password = ((Json_List_Account)ComboBox_Accounts.SelectedItem).Password.Decrypt_AES();
158+
Live_Information = (Launcher_Value.Launcher_Select_Server_JSON.Server_Authentication_Version ?? string.Empty).
159+
HashType().Login_Formater(
160+
(ComboBox_Accounts.SelectedItem as Json_List_Account).Email.Decrypt_AES(),
161+
(ComboBox_Accounts.SelectedItem as Json_List_Account).Password.Decrypt_AES());
158162
Button_Login.Text = "Login".ToUpper();
159163
}
160164
else
@@ -165,43 +169,12 @@ private void LoginButton_Click(object? sender, EventArgs? e)
165169
}
166170
else
167171
{
168-
switch (Authentication.HashType(Launcher_Value.Launcher_Select_Server_JSON.Server_Authentication_Version ?? string.Empty))
169-
{
170-
case AuthHash.H10:
171-
Email = Input_Email.Text.ToString();
172-
Password = Input_Password.Text.ToString();
173-
break;
174-
case AuthHash.H11:
175-
Email = Input_Email.Text.ToString();
176-
Password = Input_Password.Text.Hash_String(0).ToLower();
177-
break;
178-
case AuthHash.H12:
179-
Email = Input_Email.Text.ToString();
180-
Password = Input_Password.Text.Hash_String(1).ToLower();
181-
break;
182-
case AuthHash.H13:
183-
Email = Input_Email.Text.ToString();
184-
Password = Input_Password.Text.Hash_String(2).ToLower();
185-
break;
186-
case AuthHash.H20:
187-
Email = Input_Email.Text.Hash_String(0).ToLower();
188-
Password = Input_Password.Text.Hash_String(0).ToLower();
189-
break;
190-
case AuthHash.H21:
191-
Email = Input_Email.Text.Hash_String(1).ToLower();
192-
Password = Input_Password.Text.Hash_String(1).ToLower();
193-
break;
194-
case AuthHash.H22:
195-
Email = Input_Email.Text.Hash_String(2).ToLower();
196-
Password = Input_Password.Text.Hash_String(2).ToLower();
197-
break;
198-
default:
199-
Log.Error("HASH TYPE: Unknown Hash Standard was Provided");
200-
return;
201-
}
172+
Live_Information = (Launcher_Value.Launcher_Select_Server_JSON.Server_Authentication_Version ?? string.Empty).
173+
HashType().Login_Formater(Input_Email.Text, Input_Password.Text);
202174
}
203175

204-
Authentication.Client("Login", Launcher_Value.Launcher_Select_Server_JSON.Server_Authentication_Post, Email, Password, string.Empty);
176+
Authentication.Client("Login", Launcher_Value.Launcher_Select_Server_JSON.Server_Authentication_Post,
177+
Live_Information.Email, Live_Information.Password, string.Empty);
205178

206179
if (string.IsNullOrWhiteSpace(Tokens.Error))
207180
{
@@ -222,55 +195,16 @@ private void LoginButton_Click(object? sender, EventArgs? e)
222195
{
223196
Save_Account.Live_Data.User_Raw_Email = Input_Email.Text.ToString();
224197
Save_Account.Live_Data.User_Raw_Password = Input_Password.Text.ToString();
225-
226-
switch (Authentication.HashType(Launcher_Value.Launcher_Select_Server_JSON.Server_Authentication_Version ?? string.Empty))
227-
{
228-
case AuthHash.H10:
229-
Save_Account.Live_Data.Saved_Server_Hash_Version = "1.0";
230-
Save_Account.Live_Data.User_Hashed_Email = string.Empty;
231-
Save_Account.Live_Data.User_Hashed_Password = string.Empty;
232-
break;
233-
case AuthHash.H11:
234-
Save_Account.Live_Data.Saved_Server_Hash_Version = "1.1";
235-
Save_Account.Live_Data.User_Hashed_Email = string.Empty;
236-
Save_Account.Live_Data.User_Hashed_Password = Input_Password.Text.Hash_String(0).ToLower();
237-
break;
238-
case AuthHash.H12:
239-
Save_Account.Live_Data.Saved_Server_Hash_Version = "1.2";
240-
Save_Account.Live_Data.User_Hashed_Email = string.Empty;
241-
Save_Account.Live_Data.User_Hashed_Password = Input_Password.Text.Hash_String(1).ToLower();
242-
break;
243-
case AuthHash.H13:
244-
Save_Account.Live_Data.Saved_Server_Hash_Version = "1.3";
245-
Save_Account.Live_Data.User_Hashed_Email = string.Empty;
246-
Save_Account.Live_Data.User_Hashed_Password = Input_Password.Text.Hash_String(2).ToLower();
247-
break;
248-
case AuthHash.H20:
249-
Save_Account.Live_Data.Saved_Server_Hash_Version = "2.0";
250-
Save_Account.Live_Data.User_Hashed_Email = Input_Email.Text.Hash_String(0).ToLower();
251-
Save_Account.Live_Data.User_Hashed_Password = Input_Password.Text.Hash_String(0).ToLower();
252-
break;
253-
case AuthHash.H21:
254-
Save_Account.Live_Data.Saved_Server_Hash_Version = "2.1";
255-
Save_Account.Live_Data.User_Hashed_Email = Input_Email.Text.Hash_String(1).ToLower();
256-
Save_Account.Live_Data.User_Hashed_Password = Input_Password.Text.Hash_String(1).ToLower();
257-
break;
258-
case AuthHash.H22:
259-
Save_Account.Live_Data.Saved_Server_Hash_Version = "2.2";
260-
Save_Account.Live_Data.User_Hashed_Email = Input_Email.Text.Hash_String(2).ToLower();
261-
Save_Account.Live_Data.User_Hashed_Password = Input_Password.Text.Hash_String(2).ToLower();
262-
break;
263-
default:
264-
Save_Account.Live_Data.Saved_Server_Hash_Version = "Unknown";
265-
Save_Account.Live_Data.User_Hashed_Email = string.Empty;
266-
Save_Account.Live_Data.User_Hashed_Password = string.Empty;
267-
Log.Error("HASH TYPE: Unknown Hash Standard was Provided");
268-
return;
269-
}
198+
Save_Account.Live_Data.Saved_Server_Hash_Version = Live_Information.Version;
199+
Save_Account.Live_Data.User_Hashed_Email = Live_Information.Email;
200+
Save_Account.Live_Data.User_Hashed_Password = Live_Information.Password;
270201
}
271202
else if (ComboBox_Accounts.SelectedItem != default)
272203
{
273-
Save_Account.Live_Data.User_Account_Index = ComboBox_Accounts.SelectedIndex.ToString();
204+
if ((ComboBox_Accounts.SelectedItem as Json_List_Account) != default)
205+
{
206+
Save_Account.Live_Data.User_Account_Index = (ComboBox_Accounts.SelectedItem as Json_List_Account).Nickname;
207+
}
274208
}
275209

276210
Save_Account.Save();
@@ -279,7 +213,7 @@ private void LoginButton_Click(object? sender, EventArgs? e)
279213
{
280214
Input_Email.Text = "EMAIL IS HIDDEN";
281215
Tokens.Warning.Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Warning);
282-
Input_Email.Text = Email;
216+
Input_Email.Text = Live_Information.Email;
283217
}
284218

285219
LoginFormElements(false);
@@ -296,8 +230,11 @@ private void LoginButton_Click(object? sender, EventArgs? e)
296230
}
297231
Input_Email.Text = "EMAIL IS HIDDEN";
298232
Tokens.Error.Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Error);
299-
Input_Email.Text = Email;
233+
Input_Email.Text = Live_Information.Email;
300234
}
235+
236+
/* Clear out from Memory */
237+
Live_Information = default;
301238
}
302239
/// <summary>
303240
///
@@ -369,7 +306,7 @@ public void Button_Register_Click(object sender, EventArgs e)
369306
}
370307
else
371308
{
372-
"Server seems to be Offline.".Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Error);
309+
"Server seems to be Offline or Unavailable. Try again Later".Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Error);
373310
}
374311
}
375312
/// <summary>
@@ -434,7 +371,10 @@ private void Client_DownloadProgressChanged_RELOADED(object _, DownloadProgressC
434371
private void MainScreen_Load(object sender, EventArgs e)
435372
{
436373
Log.Visuals("CORE: Loading Main Screen");
437-
Application.OpenForms[this.Name].Activate();
374+
if(!Screen_Parent.Screen_Instance.DisposedForm())
375+
{
376+
Application.OpenForms[Screen_Parent.Screen_Instance.Name].Activate();
377+
}
438378

439379
if (!string.IsNullOrWhiteSpace(BuildInformation.SHORT_INFO_WITH_SECONDS))
440380
{
@@ -481,6 +421,7 @@ private void MainScreen_Load(object sender, EventArgs e)
481421
Input_Password.Visible = !Save_Settings.Account_Manager();
482422
Picture_Input_Email.Visible = !Save_Settings.Account_Manager();
483423
Picture_Input_Password.Visible = !Save_Settings.Account_Manager();
424+
CheckBox_Remember_Us.Visible = !Save_Settings.Account_Manager();
484425

485426
/* Display Server List Dialog if Server IP Doesn't Exist */
486427
if (string.IsNullOrWhiteSpace(Save_Account.Live_Data.Saved_Server_Address))
@@ -568,11 +509,38 @@ private void MainScreen_Load(object sender, EventArgs e)
568509

569510
Log.Completed("SERVERLIST: All done");
570511
}
571-
else { ComboBox_Server_List_SelectedIndexChanged(sender, e); Log.Completed("SERVERLIST: Empty List. Not Setting Index"); }
512+
else
513+
{
514+
ComboBox_Server_List_SelectedIndexChanged(sender, e);
515+
Log.Completed("SERVERLIST: Empty List. Not Setting Index");
516+
}
517+
}
518+
catch (Exception Error)
519+
{
520+
LogToFileAddons.OpenLog("Server List", string.Empty, Error, string.Empty, true);
521+
}
522+
}
523+
524+
if (!string.IsNullOrWhiteSpace(Save_Account.Live_Data.User_Account_Index) && Save_Settings.Account_Manager())
525+
{
526+
try
527+
{
528+
if (Screen_Account_Manager.Accounts_Cache.Count != 0)
529+
{
530+
if (Screen_Account_Manager.Accounts_Cache.Find(i => string.Equals(i.Nickname, Save_Account.Live_Data.User_Account_Index)) != default)
531+
{
532+
var index = Screen_Account_Manager.Accounts_Cache.FindIndex(i => string.Equals(i.Nickname, Save_Account.Live_Data.User_Account_Index));
533+
534+
if (index >= 0)
535+
{
536+
ComboBox_Accounts.SelectedIndex = index;
537+
}
538+
}
539+
}
572540
}
573541
catch (Exception Error)
574542
{
575-
LogToFileAddons.OpenLog("Serverlist", string.Empty, Error, string.Empty, true);
543+
LogToFileAddons.OpenLog("Account List", string.Empty, Error, string.Empty, true);
576544
}
577545
}
578546

SBRW.Launcher.Net/App/UI_Forms/Main_Screen/Screen_Main_Visuals.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,9 @@ private void LoginFormElements(bool hideElements)
477477
Label_Information_Window.Text = "Enter Your Account Information to Log In".ToUpper();
478478
}
479479

480-
CheckBox_Remember_Us.Visible = hideElements;
481480
Button_Login.Visible = hideElements;
482-
483481
Button_Register.Visible = hideElements;
482+
484483
if (Save_Settings.Account_Manager())
485484
{
486485
ComboBox_Accounts.Visible = hideElements;
@@ -495,6 +494,7 @@ private void LoginFormElements(bool hideElements)
495494
/* Input Strokes */
496495
Picture_Input_Email.Image = Picture_Input_Email.Icon_Order(SVG_Icon.Input_Box_Email, SVG_Color.Base);
497496
Picture_Input_Password.Image = Picture_Input_Password.Icon_Order(SVG_Icon.Input_Box_Password, SVG_Color.Base);
497+
CheckBox_Remember_Us.Visible = hideElements;
498498
}
499499

500500
LinkLabel_Forgot_Password.Visible = hideElements;

SBRW.Launcher.Net/SBRW.Launcher.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@
7575
</ItemGroup>
7676
<ItemGroup>
7777
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.1.0" />
78-
<PackageReference Include="SBRW.Launcher.Core" Version="0.5.0" />
79-
<PackageReference Include="SBRW.Launcher.Core.Discord" Version="0.5.0" />
78+
<PackageReference Include="SBRW.Launcher.Core" Version="0.5.1" />
79+
<PackageReference Include="SBRW.Launcher.Core.Discord" Version="0.5.1" />
8080
<PackageReference Include="SBRW.Launcher.Core.Downloader" Version="0.3.8" />
8181
<PackageReference Include="SBRW.Launcher.Core.Downloader.LZMA" Version="0.3.2" />
82-
<PackageReference Include="SBRW.Launcher.Core.Extra" Version="0.5.0" />
83-
<PackageReference Include="SBRW.Launcher.Core.Proxy" Version="0.5.0" />
82+
<PackageReference Include="SBRW.Launcher.Core.Extra" Version="0.5.1" />
83+
<PackageReference Include="SBRW.Launcher.Core.Proxy" Version="0.5.1" />
8484
<PackageReference Include="SBRW.Launcher.Core.Theme" Version="0.3.1" />
8585
<PackageReference Include="SBRW.Nancy" Version="2.0.13" />
8686
<PackageReference Include="SBRW.Nancy.Hosting.Self" Version="2.0.11" />

SBRW.Launcher.RunTime/InsiderKit/BuildInformation.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public class BuildInformation
99
{
1010
/* Current month, day, year (2 digits), and letter! Ex: 12-15-20-A */
1111
/* If a second build gets release within the same day bump letter version up (No R2 or D2)*/
12-
const string DATE = "06-23-2024";
13-
const string DATE_SHORT = "06-23-24";
14-
const string TIME = "0106";
15-
const string TIME_SECONDS = "40";
12+
const string DATE = "06-24-2024";
13+
const string DATE_SHORT = "06-24-24";
14+
const string TIME = "0157";
15+
const string TIME_SECONDS = "44";
1616
const string TIME_ZONE = "-07:00";
1717
/// <summary>
1818
/// Build Information <i>(Full Information)</i>

SBRW.Launcher.RunTime/LauncherCore/Client/Auth/Authentication.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace SBRW.Launcher.RunTime.LauncherCore.Client.Auth
1818
{
19-
class Authentication
19+
public static class Authentication
2020
{
2121
private static int ServerErrorCode { get; set; }
2222
private static string LoginResponse { get; set; } = string.Empty;
@@ -31,7 +31,7 @@ class Authentication
3131
/// <returns>Receives UserId and Auth Key for Login. Sends Email and Password to Server</returns>
3232
/// <param name="ConnectionProtocol">Connection Protocol: Check AuthProtocol</param>
3333
/// <param name="Method">Form Type: "Login" or "Register"</param>
34-
public static void Client(string Method, bool Modern_Auth, String Email, String Password, String Token)
34+
public static void Client(string Method, bool Modern_Auth, string Email, string Password, string Token)
3535
{
3636
try
3737
{
@@ -302,7 +302,7 @@ public static void Client(string Method, bool Modern_Auth, String Email, String
302302
/// Hash Method (Used how to Authenticate Logins)
303303
/// </summary>
304304
/// <returns>A hash type standard that is used on the server</returns>
305-
public static AuthHash HashType(string HType)
305+
public static AuthHash HashType(this string HType)
306306
{
307307
if (!string.IsNullOrWhiteSpace(HType))
308308
{

0 commit comments

Comments
 (0)