/// <summary> /// Retrieves a user with information matching the current login info on the form. If no user /// is found, returns null. /// </summary> /// <returns></returns> private user ValidateLogin() { user u = new user(); DataTable matches = u.Search("SELECT * FROM USERS WHERE username = '******' AND password = '******'"); if (matches.Rows.Count > 0) { u.Load(matches.Rows[0]); return(u); } else { return(null); } }
private void cmdSave_Click(object sender, EventArgs e) { if (_formUser.VerifyPassword(txtOldPassword.Text)) { if (txtNewPassword1.Text == txtNewPassword2.Text) { _formUser.password = _formUser.Hash(txtNewPassword1.Text); _formUser.Save(); MessageBox.Show(this, "Your new password is now saved. You can use it the next time you login.", "New password"); Close(); } else { MessageBox.Show(this, "Your passwords do not match.", "Passwords don't match"); } } else { MessageBox.Show(this, "Your old password is incorrect.", "Old password wrong"); } }