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 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");
            }
        }
Exemple #3
0
        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");
                }
            }
        }