private void ChangePasswordButton_Click(object sender, EventArgs e) { string oldhashedPass = MySQLFunctions.getPass(userInfo.getCurrentEmail());; if (ChangePasswordCurrentPassword.Text != "" && ChangePasswordNew.Text != "" && ChangePasswordConfirmNew.Text != "") { if (ChangePasswordNew.Text == ChangePasswordConfirmNew.Text) { if (MySQLFunctions.GenerateHash(ChangePasswordNew.Text, userInfo.getCurrentEmail()) == oldhashedPass) { MySQLFunctions.SQLCommand($"UPDATE usertable SET password = "******"'{MySQLFunctions.GenerateHash(ChangePasswordNew.Text, userInfo.getCurrentEmail())}' WHERE userID = {userInfo.getCurrentUser()}"); } else { MessageBox.Show("Current password is incorrect"); } } else { MessageBox.Show("Passwords must match"); } } else { MessageBox.Show("Please fill in all the fields"); } }
private void button1_Click(object sender, EventArgs e) { if (usernameInput.Text != "" && passwordInput.Text != "") { if (MySQLFunctions.GenerateHash(passwordInput.Text, usernameInput.Text) == MySQLFunctions.getPass(usernameInput.Text)) { userInfo.setCurrentUser(MySQLFunctions.getUserIDFromEmail(usernameInput.Text)); userInfo.setCurrentEmail(usernameInput.Text); this.Hide(); transition.openClassView(); this.Close(); } else { MessageBox.Show("Email and password do not match"); } } }
private void ChangeEmailButton_Click(object sender, EventArgs e) { var comparedPassword = MySQLFunctions.GenerateHash(ChangeEmailPassword.Text, ChangeEmailCurrentEmail.Text); if (ChangeEmailNewEmail.Text.Contains("@snhu.edu")) { if (comparedPassword == MySQLFunctions.getPass(ChangeEmailCurrentEmail.Text)) { MySQLFunctions.SQLCommand($"UPDATE usertable SET email = '{ChangeEmailNewEmail.Text}' WHERE userID = {userInfo.getCurrentUser()}"); MySQLFunctions.SQLCommand($"UPDATE usertable SET password = '******' WHERE userID = {userInfo.getCurrentUser()}"); } else { MessageBox.Show("Current Email or password is wrong"); } } else { MessageBox.Show("New email is invalid"); } }
private void SignUpButton_Click(object sender, EventArgs e) { if (SignUpButton.BackColor == goodInput) { //Get first and last name from email string email = Email.Text; string firstName = email.Split('.')[0]; string lastName = email.Split('.')[1]; lastName = lastName.Split('@')[0]; try { NewUser(Int32.Parse(StudentID.Text), firstName, lastName, Email.Text, MySQLFunctions.GenerateHash(Password.Text, Email.Text)); } catch (ArgumentException) { return; } userInfo.setCurrentUser(Int32.Parse(StudentID.Text)); this.Hide(); transition.openScheduleInput(); this.Close(); } }