private void butGiveAccess_Click(object sender, EventArgs e) { if (butGiveAccess.Text == "Provide Online Access") //When form open opens with a blank password { if (PrefC.GetString(PrefName.PatientPortalURL) == "") { //User probably hasn't set up the patient portal yet. MsgBox.Show(this, "Patient Facing URL is required to be set before granting online access. Click Setup to set the Patient Facing URL."); return; } string error; if (!UserWebs.ValidatePatientAccess(_patCur, out error)) { MessageBox.Show(error); return; } Cursor = Cursors.WaitCursor; //1. Fill password. string passwordGenerated = UserWebs.GenerateRandomPassword(8); textOnlinePassword.Text = passwordGenerated; //2. Make the username and password editable in case they want to change it. textOnlineUsername.ReadOnly = false; textOnlinePassword.ReadOnly = false; //3. Save password to db. // We only save the hash of the generated password. string passwordHashed = Userods.HashPassword(passwordGenerated, false); _userWebCur.Password = passwordHashed; UserWebs.Update(_userWebCur, _userWebOld); _userWebOld.Password = passwordHashed; //Update _userWebOld in case the user changes password manually. //4. Insert EhrMeasureEvent EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = DateTime.Now; newMeasureEvent.EventType = EhrMeasureEventType.OnlineAccessProvided; newMeasureEvent.PatNum = _userWebCur.FKey; newMeasureEvent.MoreInfo = ""; EhrMeasureEvents.Insert(newMeasureEvent); //5. Rename button butGiveAccess.Text = "Remove Online Access"; Cursor = Cursors.Default; } else //remove access { Cursor = Cursors.WaitCursor; //1. Clear password textOnlinePassword.Text = ""; //2. Make in uneditable textOnlinePassword.ReadOnly = true; //3. Save password to db _userWebCur.Password = textOnlinePassword.Text; UserWebs.Update(_userWebCur, _userWebOld); _userWebOld.Password = textOnlinePassword.Text; //Update PatOld in case the user changes password manually. //4. Rename button butGiveAccess.Text = "Provide Online Access"; Cursor = Cursors.Default; } }
private void butGenerate_Click(object sender, EventArgs e) { if (textOnlinePassword.ReadOnly) { MessageBox.Show("Please use the Provide Online Access button first."); return; } Cursor = Cursors.WaitCursor; string passwordGenerated = UserWebs.GenerateRandomPassword(8); textOnlinePassword.Text = passwordGenerated; // We only save the hash of the generated password. _userWebCur.LoginDetails = Authentication.GenerateLoginDetailsSHA512(passwordGenerated); UserWebs.Update(_userWebCur, _userWebOld); _userWebOld.LoginDetails = _userWebCur.LoginDetails; Cursor = Cursors.Default; }
private void butGenerate_Click(object sender, EventArgs e) { if (textOnlinePassword.ReadOnly) { MessageBox.Show("Please use the Provide Online Access button first."); return; } Cursor = Cursors.WaitCursor; string passwordGenerated = UserWebs.GenerateRandomPassword(8); textOnlinePassword.Text = passwordGenerated; // We only save the hash of the generated password. string passwordHashed = Userods.HashPassword(passwordGenerated, false); _userWebCur.Password = passwordHashed; UserWebs.Update(_userWebCur, _userWebOld); _userWebOld.Password = passwordHashed; //Update PatOld in case the user changes password manually. Cursor = Cursors.Default; }