29
29
using System . IO ;
30
30
using System . Net ;
31
31
using System . Windows . Forms ;
32
+ using System . Linq ;
33
+ using SBRW . Launcher . Core . Extension . List_ ;
34
+ using SBRW . Launcher . RunTime . LauncherCore . Client . Auth . JSON ;
32
35
#endregion
33
36
34
37
namespace SBRW . Launcher . App . UI_Forms . Main_Screen
@@ -142,19 +145,20 @@ private void LoginButton_Click(object? sender, EventArgs? e)
142
145
143
146
Tokens . Clear ( ) ;
144
147
145
- string Email ;
146
- string Password ;
147
-
148
148
Tokens . IPAddress = Launcher_Value . Launcher_Select_Server_Data . IPAddress ;
149
149
Tokens . ServerName = ServerListUpdater . ServerName ( "Login" ) ;
150
150
151
+ AuthenticationGeneration Live_Information = default ;
152
+
151
153
if ( Save_Settings . Account_Manager ( ) )
152
154
{
153
155
if ( ComboBox_Accounts . SelectedItem != default )
154
156
{
155
157
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 ( ) ) ;
158
162
Button_Login . Text = "Login" . ToUpper ( ) ;
159
163
}
160
164
else
@@ -165,43 +169,12 @@ private void LoginButton_Click(object? sender, EventArgs? e)
165
169
}
166
170
else
167
171
{
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 ) ;
202
174
}
203
175
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 ) ;
205
178
206
179
if ( string . IsNullOrWhiteSpace ( Tokens . Error ) )
207
180
{
@@ -222,55 +195,16 @@ private void LoginButton_Click(object? sender, EventArgs? e)
222
195
{
223
196
Save_Account . Live_Data . User_Raw_Email = Input_Email . Text . ToString ( ) ;
224
197
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 ;
270
201
}
271
202
else if ( ComboBox_Accounts . SelectedItem != default )
272
203
{
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
+ }
274
208
}
275
209
276
210
Save_Account . Save ( ) ;
@@ -279,7 +213,7 @@ private void LoginButton_Click(object? sender, EventArgs? e)
279
213
{
280
214
Input_Email . Text = "EMAIL IS HIDDEN" ;
281
215
Tokens . Warning . Message_Box ( MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
282
- Input_Email . Text = Email ;
216
+ Input_Email . Text = Live_Information . Email ;
283
217
}
284
218
285
219
LoginFormElements ( false ) ;
@@ -296,8 +230,11 @@ private void LoginButton_Click(object? sender, EventArgs? e)
296
230
}
297
231
Input_Email . Text = "EMAIL IS HIDDEN" ;
298
232
Tokens . Error . Message_Box ( MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
299
- Input_Email . Text = Email ;
233
+ Input_Email . Text = Live_Information . Email ;
300
234
}
235
+
236
+ /* Clear out from Memory */
237
+ Live_Information = default ;
301
238
}
302
239
/// <summary>
303
240
///
@@ -369,7 +306,7 @@ public void Button_Register_Click(object sender, EventArgs e)
369
306
}
370
307
else
371
308
{
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 ) ;
373
310
}
374
311
}
375
312
/// <summary>
@@ -434,7 +371,10 @@ private void Client_DownloadProgressChanged_RELOADED(object _, DownloadProgressC
434
371
private void MainScreen_Load ( object sender , EventArgs e )
435
372
{
436
373
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
+ }
438
378
439
379
if ( ! string . IsNullOrWhiteSpace ( BuildInformation . SHORT_INFO_WITH_SECONDS ) )
440
380
{
@@ -481,6 +421,7 @@ private void MainScreen_Load(object sender, EventArgs e)
481
421
Input_Password . Visible = ! Save_Settings . Account_Manager ( ) ;
482
422
Picture_Input_Email . Visible = ! Save_Settings . Account_Manager ( ) ;
483
423
Picture_Input_Password . Visible = ! Save_Settings . Account_Manager ( ) ;
424
+ CheckBox_Remember_Us . Visible = ! Save_Settings . Account_Manager ( ) ;
484
425
485
426
/* Display Server List Dialog if Server IP Doesn't Exist */
486
427
if ( string . IsNullOrWhiteSpace ( Save_Account . Live_Data . Saved_Server_Address ) )
@@ -568,11 +509,38 @@ private void MainScreen_Load(object sender, EventArgs e)
568
509
569
510
Log . Completed ( "SERVERLIST: All done" ) ;
570
511
}
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
+ }
572
540
}
573
541
catch ( Exception Error )
574
542
{
575
- LogToFileAddons . OpenLog ( "Serverlist " , string . Empty , Error , string . Empty , true ) ;
543
+ LogToFileAddons . OpenLog ( "Account List " , string . Empty , Error , string . Empty , true ) ;
576
544
}
577
545
}
578
546
0 commit comments