private void btnAccept_Click(object sender, EventArgs e) { //Authenticate user userAccount = ApplicationObjects.AuthenticateUser(this.txtUserID.Text, this.txtOldPwd.Text); if (userAccount == null || userAccount.HighestPermission == null) { DialogResult result = MessageBox.Show("Failed to authenticate user.", "Authentication failed!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand); if (result == DialogResult.Retry) { return; } else { _loginForm.Logout(); this.Close(); return; } } //Verify the text boxes are not empty if (!(this.txtNewPwd.Text == String.Empty) && !(this.txtConfirmPwd.Text == String.Empty)) { //Validate new and confirmed passwords match if (String.Compare(this.txtNewPwd.Text, this.txtConfirmPwd.Text) != 0) { DialogResult result = MessageBox.Show("Your new and confirmed passwords did not match.", "Password mismatch", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand); if (result == DialogResult.Retry) { return; } else { _loginForm.Logout(); this.Close(); return; } } } else { DialogResult result = MessageBox.Show("Both new and confirmed password boxes must be populated.", "Invalid input!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand); if (result == DialogResult.Retry) { return; } else { _loginForm.Logout(); this.Close(); return; } } //Change password userAccount.PasswordHash = this.txtNewPwd.Text; ApplicationObjects.ChangePassword(userAccount); //Logout to re-authenticate MessageBox.Show("Password change complete. Please re-log in.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.None); _loginForm.Logout(); this.Close(); }