private void LoginButton_OnClick(object sender, RoutedEventArgs e) { try { var username = LoginUsernameBox.Text.ToLower(); var password = LoginPasswordBox.Password; var regionData = RiotClientData.ReadSystemRegionData(Path.Combine(StaticVars.IcyWindLocation, "IcyWindAssets", "system", "system.yaml"), RegionComboBox.SelectedValue.ToString()); var region = RegionComboBox.SelectedValue.ToString(); var thread = new Thread((async() => { var openId = RiotAuth.GetOpenIdConfig(); await RiotAuth.Login(this, Dispatcher, username, password, region, openId, false, () => Reload_OnClick(this, null)); })); thread.Start(); } catch { UserInterfaceCore.HolderPage.ShowNotification(UserInterfaceCore.ShortNameToString("LoginErrorGeneric")); } LoginGrid.Visibility = Visibility.Hidden; }
private void Login_Click(object sender, RoutedEventArgs e) { LoginProgressBar.Visibility = Visibility.Visible; var loginCred = new LoginCredentials { Username = Username.Text, Password = Password.Password }; //Missing information. This is done to save bandwidth for the user. // if (string.IsNullOrWhiteSpace(loginCred.Username) || string.IsNullOrWhiteSpace(loginCred.PasswordHash)) { UserInterfaceCore.HolderPage.ShowNotification(UserInterfaceCore.ShortNameToString("NoCred")); LoginProgressBar.Visibility = Visibility.Hidden; return; } var t = new Thread(async() => { var accountInfo = AccountManager.GetAccountInfo(loginCred); // Failed login information if (!string.IsNullOrWhiteSpace(accountInfo.Error)) { switch (accountInfo.Error) { case "InvalidCred": case "UserBanned": case "EmailNotVerified": await Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { UserInterfaceCore.HolderPage.ShowNotification(UserInterfaceCore.ShortNameToString(accountInfo.Error)); LoginProgressBar.Visibility = Visibility.Hidden; Password.Clear(); })); break; default: await Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { UserInterfaceCore.HolderPage.ShowNotification(UserInterfaceCore.ShortNameToString("LoginErrorGeneric")); LoginProgressBar.Visibility = Visibility.Hidden; Password.Clear(); })); break; } return; } if (!string.IsNullOrWhiteSpace(accountInfo.TwoFactor)) { LoginProgressBar.Visibility = Visibility.Hidden; switch (accountInfo.Error) { //TODO: Implement a way to input a code for 2FA //TODO: Add an option to exclude 2FA for certain known devices of IP ADDRESSES case "CheckEmail": case "CheckText": await Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { UserInterfaceCore.HolderPage.ShowNotification(UserInterfaceCore.ShortNameToString(accountInfo.Error)); LoginProgressBar.Visibility = Visibility.Hidden; })); break; default: await Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { UserInterfaceCore.HolderPage.ShowNotification(UserInterfaceCore.ShortNameToString("LoginErrorGeneric")); LoginProgressBar.Visibility = Visibility.Hidden; })); break; } return; } //This is the OpenId config used to login. I use a custom //Implementation which may not fully represent OpenId but //It gets the job done var openId = RiotAuth.GetOpenIdConfig(); //The SHA1 Hash of the password is used as the password //To get the accounts from the servers. The MD5 hash of that //Password is the AES key. This may need to change to a different //Hashing algorithm, and maybe the encryption should include //A part form the IcyWindAuth server which is used to decrypt var aesKey = MD5.Hash(Password.Password); StaticVars.AccountInfo = accountInfo; StaticVars.LoginCred = loginCred; StaticVars.Password = aesKey; //This is done to stop people who are not devs or donators from accessing IcyWind in Beta // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (!accountInfo.IsDev && !accountInfo.IsPaid && false) { await Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { UserInterfaceCore.HolderPage.ShowNotification(UserInterfaceCore.ShortNameToString("FeaturedDonator")); })); return; } if (!string.IsNullOrWhiteSpace(accountInfo.Accounts)) { foreach (var account in JsonConvert.DeserializeObject <string[]>(accountInfo.Accounts)) { var copyAccount = account; var mm = copyAccount.Length % 4; if (mm > 0) { copyAccount += new string('=', 4 - mm); } var data = Convert.FromBase64String(copyAccount); var accountAsJson = Encoding.UTF8.GetString(data); var decodedString = JsonConvert.DeserializeObject <IcyWindRiotAccountCrypted>(accountAsJson); if (StaticVars.LoginCred.AccountData == null) { StaticVars.LoginCred.AccountData = new List <IcyWindRiotAccountCrypted>(); } StaticVars.LoginCred.AccountData.Add(decodedString); var accountDecrypted = AES.DecryptBase64(aesKey, decodedString.CryptString); var accountDetail = JsonConvert.DeserializeObject <IcyWindRiotAccountInfo>(accountDecrypted); await RiotAuth.Login(this, Dispatcher, accountDetail.Username, accountDetail.Password, accountDetail.Region, openId, true, null); } } else { StaticVars.LoginCred.AccountData = new List <IcyWindRiotAccountCrypted>(); } await Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { UserInterfaceCore.ChangeView(typeof(AccountSelectorPage)); //Fade out the audio var timer = new System.Timers.Timer { Interval = 50 }; timer.Elapsed += (obj, evt) => { Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { player.Volume -= 0.01; if (!(player.Volume <= 0)) { return; } player.Stop(); timer.Stop(); Video.Stop(); })); }; timer.Start(); LoginProgressBar.Visibility = Visibility.Hidden; })); }); t.Start(); }