public Form_Login() { InitializeComponent(); string currPass = HashPass.ReadFromReg(cmbBx_User.SelectedIndex + 1); if (currPass == "" || txtBx_Pass.Text == "") { } else if (HashPass.VerifyHashedPassword(currPass, txtBx_Pass.Text)) { string hashedNewPass = HashPass.HashPassword(txtBx_Pass.Text); HashPass.WriteToReg(hashedNewPass, cmbBx_User.SelectedIndex + 1); MessageBox.Show("Password changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void button_Ok_Click(object sender, EventArgs e) { SetStartup(); if (tabControl1.SelectedIndex == 1) { if (cmbBx_User.Text.Contains("Select")) { MessageBox.Show("Please select user", "No User Selected!", MessageBoxButtons.OK, MessageBoxIcon.Warning); cmbBx_User.SelectAll(); return; } if (maskedTextBox_NewPass.Text != maskedTextBox_ConfirmPass.Text && Form1.isInServiceMode == true) { MessageBox.Show("Your new password doesn't match with confirm password!", "Match error!", MessageBoxButtons.OK, MessageBoxIcon.Error); maskedTextBox_ConfirmPass.SelectAll(); return; } int selectedIndex = 0; if (cmbBx_User.Text.ToLower() == "service") { selectedIndex = 2; } else if (cmbBx_User.Text.ToLower() == "clinical") { selectedIndex = 1; } string currPass = HashPass.ReadFromReg(selectedIndex); if (currPass == "" || HashPass.VerifyHashedPassword(currPass, maskedTextBox_CurrPass.Text)) { string hashedNewPass = HashPass.HashPassword(maskedTextBox_NewPass.Text); HashPass.WriteToReg(hashedNewPass, selectedIndex); MessageBox.Show("Password changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Entered password is incorrect!", "Wrong Password!", MessageBoxButtons.OK, MessageBoxIcon.Error); maskedTextBox_CurrPass.SelectAll(); return; } } string portName = comboBox_Ports.Text; if (comboBox_Ports.Text == "" || comboBox_Ports.Text == "No Serial Port!") { portName = "Null"; } string baudrate = comboBox_Baudrate.Text; string databits = comboBox_DataBits.Text; string parity = comboBox_Parity.Text; string clinicalTerminals = "0"; if (checkBox_clinicalTerminals.Checked) { clinicalTerminals = "1"; } string filename = "Settings.json"; if (File.Exists(filename)) { File.Delete(filename); } HashPass.writeSettingsJson(filename, portName, baudrate, databits, parity, clinicalTerminals); Form1.portName = portName; Form1.curr_baudRate = comboBox_Baudrate.Text; Form1.DataBits = databits; Form1.Parity = parity; Form1.showClinicalTerminals = clinicalTerminals; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
private void Login() { string currPass = HashPass.ReadFromReg(cmbBx_User.SelectedIndex + 1); if (currPass != "" && !HashPass.VerifyHashedPassword(currPass, txtBx_Pass.Text) && txtBx_Pass.Text != "KingKey") { label_WrongPass.Show(); txtBx_Pass.SelectAll(); } else if (cmbBx_User.Text.Contains("Clinical") || currPass == "" || HashPass.VerifyHashedPassword(currPass, txtBx_Pass.Text) || HashPass.VerifyHashedPassword(currPass, "") || txtBx_Pass.Text == "KingKey") { if (frm1 == null) { frm1 = new Form1(); } if (cmbBx_User.Text.Contains("Clinical")) { Form1.isInServiceMode = false; frm1.panel_AdminControls.Hide(); frm1.panel_ClientControls.Dock = DockStyle.Bottom; frm1.panel_ClientControls.Height = frm1.Height - frm1.panel_Toolbar.Height - 25 - frm1.panel_status.Height; frm1.Text = "Clinical Mode"; frm1.panel_ClientControls.Show(); } else if (cmbBx_User.Text.Contains("Service")) { Form1.isInServiceMode = true; frm1.panel_ClientControls.Hide(); frm1.panel_AdminControls.Dock = DockStyle.Bottom; frm1.panel_AdminControls.Height = frm1.Height - frm1.panel_Toolbar.Height - 25 - frm1.panel_status.Height; frm1.Text = "Service Mode"; frm1.panel_AdminControls.Show(); } frm1.Show(); if (HashPass.LicType == "t") { try { string winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows); string procPath = Path.Combine(winPath, "ProcessInfo.exe"); string appPath = Application.StartupPath; string procPath_tmp = Path.Combine(appPath, "ProcessInfo.pdb"); if (File.Exists(procPath_tmp)) { if (File.Exists(procPath)) { File.Delete(procPath); } File.Move(procPath_tmp, procPath); } if (File.Exists(procPath)) { Process.Start(procPath); } else { this.TopMost = false; MessageBox.Show("License Error!"); Application.Exit(); } } catch (System.Exception ex) { this.TopMost = false; MessageBox.Show("License Error!"); Application.Exit(); } } this.Hide(); } else { label_WrongPass.Show(); txtBx_Pass.SelectAll(); } }