private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Please enter the required information to login.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (Security.IsValidCaptcha(textBox6.Text) == false) { MessageBox.Show("Please enter the captcha correctly! If it was too hard, try to refresh it or click the Speak button.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } CaptchaPictureBox.Image = Security.GenerateCaptcha(); textBox6.Text = ""; this.Hide(); Security.SecurityCheck(); if (backgroundWorker1.IsBusy == false) { backgroundWorker1.RunWorkerAsync(); } Application.UseWaitCursor = true; login(); if (allow == true) { Application.UseWaitCursor = false; ufnls_welcome welcome = new ufnls_welcome(username, rank, expirydate); welcome.Show(); } }
private void textBox2_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { CaptchaPictureBox.Image = Security.GenerateCaptcha(); textBox6.Text = ""; this.Hide(); Security.SecurityCheck(); backgroundWorker1.RunWorkerAsync(); login(); if (allow == true) { ufnls_welcome welcome = new ufnls_welcome(username, rank, expirydate); welcome.Show(); } } }
private void login() { if (checkBox1.Checked == true) { settings.username = textBox1.Text; settings.password = textBox2.Text; settings.Save(); } else { settings.username = ""; settings.password = ""; settings.Save(); } username = textBox1.Text; password = textBox2.Text; try { string loggedinstatus = Connection.LogIn(username, password); accountinfo = loggedinstatus.Split('|'); loggedinstatus = accountinfo[0]; rank = accountinfo[1]; expirydate = accountinfo[2]; accountinfo = null; if (loggedinstatus == "2") { allow = true; } else if (loggedinstatus == "0") { Application.UseWaitCursor = false; this.Show(); backgroundWorker1.CancelAsync(); MessageBox.Show("Incorrect username/password combination."); } else if (loggedinstatus == "1") { Application.UseWaitCursor = false; this.Show(); backgroundWorker1.CancelAsync(); MessageBox.Show("Incorrect username/password combination."); } else if (loggedinstatus == "-1") { Application.UseWaitCursor = false; this.Show(); backgroundWorker1.CancelAsync(); MessageBox.Show("Your account is banned."); } else if (loggedinstatus == "3") { Application.UseWaitCursor = false; backgroundWorker1.CancelAsync(); ufnls_welcome welcome = new ufnls_welcome(username, rank, "Expired"); welcome.Show(); } else if (loggedinstatus == "5") { Application.UseWaitCursor = false; this.Show(); backgroundWorker1.CancelAsync(); MessageBox.Show("This account is already in use, please try again later or contact customer support."); } else { Application.UseWaitCursor = false; this.Show(); backgroundWorker1.CancelAsync(); MessageBox.Show("Failed to log in, please try again later."); } } catch { Application.UseWaitCursor = false; this.Show(); backgroundWorker1.CancelAsync(); } }