Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void loginButton_Click(object sender, EventArgs e)
- {
- username = usernameTextBox.Text;
- password = passwordTextBox.Text;
- if (String.IsNullOrEmpty(username))
- {
- MessageBox.Show("Please input username!", "Warning!",
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (String.IsNullOrEmpty(password))
- {
- MessageBox.Show("Please input password!", "Warning!",
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- loginButton.Text = "Logging...";
- string usernameResult = Database.access.GetColumnData(NCLib.ValueType.VALUETYPE_STRING, "accounts", "username", "username", username, true);
- string passwordResult = Database.access.GetColumnData(NCLib.ValueType.VALUETYPE_STRING, "accounts", "password", "password", Hash.SHA1(password), true);
- if (usernameResult != username)
- {
- MessageBox.Show("This account doesn't exist.", "Error!",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- loginButton.Text = "Login";
- return;
- }
- if (usernameResult == username && passwordResult == Hash.SHA1(password))
- {
- string hwidInfo = HWID.getHWID().ToString().Replace(" ", "");
- string hwidResult = Database.access.GetColumnData(NCLib.ValueType.VALUETYPE_STRING, "accounts", "hwid", "username", username, true);
- string rankResult = Database.access.GetColumnData(NCLib.ValueType.VALUETYPE_INT32, "accounts", "rank", "username", username, true);
- if (hwidInfo != hwidResult && rankResult != "1" && rankResult != "3")
- {
- MessageBox.Show("Your HWID doesn't match. Your account has been locked. Ask for a reset.", "Error!",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- Database.access.Update("accounts", "rank", "1", "username", username);
- loginButton.Text = "Login";
- return;
- }
- if (rankResult == "0")
- {
- MessageBox.Show("Your account is banned.", "Error!",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- loginButton.Text = "Login";
- return;
- }
- else if (rankResult == "1")
- {
- MessageBox.Show("Your account is locked due to HWID change.", "Error!",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- loginButton.Text = "Login";
- return;
- }
- else if (rankResult != "2" && rankResult != "3")
- {
- MessageBox.Show("Your rank isn't recognized.", "Error!",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- loginButton.Text = "Login";
- return;
- }
- string[] logValues = { Convert.ToString(0), username, Functions.getIP(), DateTime.Now.ToString(), "Client login" };
- Database.access.Insert("logs", logValues);
- Database.access.Update("accounts", "ip", Functions.getIP(), "username", username);
- Database.access.Update("accounts", "pcname", Functions.getPCName(), "username", username);
- this.Hide();
- var result2 = new TestApp().ShowDialog();
- if (result2 == DialogResult.Cancel)
- this.Close();
- }
- else
- {
- MessageBox.Show("The username or the password is wrong, please try again.", "Error!",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- loginButton.Text = "Login";
- }
Add Comment
Please, Sign In to add comment