private void btnSubmit_Click(object sender, EventArgs e) { if (PasswordDB.Authenticate(txtOldPass.Text) == true) { checkOPC = true; if (txtNewPass1.Text.Equals(txtNewPass2.Text) == true) { checkNPM = true; if (PasswordDB.HasPasswordAlreadyBeenUsed(txtNewPass1.Text) == false) { checkNPU = true; if (txtNewPass1.Text.Length >= 8) { checkNPLE = true; string hint; if (string.IsNullOrEmpty(txtHint.Text) == true) { hint = "******No hint available******"; } else { hint = txtHint.Text; } UpdatePassword(txtNewPass1.Text, hint); } else { checkNPLE = false; MessageBox.Show("Please enter a longer password.", "Error: password too short"); } } else { checkNPU = false; MessageBox.Show("You have used this password in the past. Please try a different password.", "Error: already used password"); } } else { checkNPM = false; MessageBox.Show("New passwords do not match. Please re-enter and try again. System is case sensitive.", "Error: passwords don't match"); } } else { checkOPC = false; MessageBox.Show("Please enter your current password correctly. System is case sensitive.", "Error: current password"); } }
private void button2_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(lblHint.Text) == true) { lblHint.Text = "Hint: " + PasswordDB.GetHint(); button2.Text = "Hide hint"; } else { lblHint.Text = ""; button2.Text = "Show hint"; } }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtPassword.Text) == false) { if (PasswordDB.Authenticate(txtPassword.Text)) { isAuthenticated = true; DialogResult = DialogResult.OK; } else { lblIncorrectPassword.Visible = true; } } }
private void frm1_Load(object sender, EventArgs e) { orgFrm = Size; orgPackge = new Rectangle(Packages.Location.X, Packages.Location.Y, Packages.Width, Packages.Height); orgProduct = new Rectangle(product.Location.X, product.Location.Y, product.Width, product.Height); frmGuardian guardian = new frmGuardian(); DialogResult result = guardian.ShowDialog(); DateTime today = DateTime.Today; DateTime passwordLastChangedDate = PasswordDB.GetLastUpdateDate(); if ((today - passwordLastChangedDate).Days >= 90) { frmNewPassword newForm = new frmNewPassword(); newForm.ninetyDayUpdate = true; DialogResult npresult = newForm.ShowDialog(); } }
private void UpdatePassword(string newPassword, string hint) { DateTime today = DateTime.Today; Password password = new Password() { PasswordInput = newPassword, Hint = hint, UpdateDate = today }; if (PasswordDB.UpdatePassword(password) == true) { MessageBox.Show("Password updated. You will be reminded in 90 days to update again", "Success!"); DialogResult = DialogResult.OK; } else { MessageBox.Show("Database error, please try again later or contact your adminstrator.", "Error"); DialogResult = DialogResult.OK; } }