Esempio n. 1
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textPassword.Text != "" && textUserName.Text.Trim() == "")
     {
         MsgBox.Show(this, "User Name cannot be blank.");
         return;
     }
     if (textUserName.Text != "" && textPassword.Text.Trim() == "")
     {
         MsgBox.Show(this, "Password cannot be blank.");
         return;
     }
     if (textUserName.Text != "" && Resellers.IsUserNameInUse(ResellerCur.PatNum, textUserName.Text))
     {
         MsgBox.Show(this, "User Name already in use.");
         return;
     }
     ResellerCur.UserName = textUserName.Text;
     if (textPassword.Text != "********")
     {
         ResellerCur.ResellerPassword = Userods.HashPassword(textPassword.Text, false);
     }
     Resellers.Update(ResellerCur);
     DialogResult = DialogResult.OK;
 }
Esempio n. 2
0
 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;
     }
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        private bool ValidateTitle()
        {
            //Key Hint: Nick Fury quote from Captain America Winter Soldier, 3 words, no spaces, CamelCased
            if (Userods.HashPassword(textTitle.Text) != KEY)
            {
                return(true);
            }
            butOK.Enabled                 = false;
            butCancel.Enabled             = false;
            tabControlExtra.SelectedTab   = tabConcept;
            tabConcept.BackColor          = Color.Black;
            labelCategory.Text            = "Protect";
            labelPriority.Text            = "The";
            labelVersion.Text             = "Program";
            comboCategory.Visible         = false;
            comboPriority.Visible         = false;
            textVersion.Visible           = false;
            butVersionPrompt.Visible      = false;
            label1.Visible                = false;
            textConcept.ReadOnly          = true;
            textConcept.TextBox.BackColor = Color.Black;
            textConcept.TextBox.ForeColor = Color.White;
            tabControlExtra.TabPages.Remove(tabCustomers);
            tabControlExtra.TabPages.Remove(tabQuotes);
            tabControlExtra.TabPages.Remove(tabSubscribers);
            tabControlExtra.TabPages.Remove(tabRequests);
            tabControlExtra.TabPages.Remove(tabBugs);
            tabControlExtra.TabPages.Remove(tabTasks);
            BackColor = Color.Black;
            foreach (Control c in this.Controls)
            {
                c.BackColor = Color.Black;
                c.ForeColor = Color.White;
            }
            Text = "AVENGINEERS MODE ACTIVE";
            string str = "";

            CDT.Class1.Decrypt(MSG, out str);
            textTitle.Text       = "Welcome Director Fury";
            textConcept.MainText = str;
            return(false);
        }
Esempio n. 5
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (_isPasswordReset)
            {
                if (textPassword.Text != textCurrent.Text || string.IsNullOrWhiteSpace(textPassword.Text))
                {
                    MsgBox.Show(this, "Passwords much match and not be empty.");
                    return;
                }
            }
            else if (!IsInSecurityWindow &&
                     Userods.HashPassword(textCurrent.Text) != Security.CurUser.Password)
            {
                MsgBox.Show(this, "Current password incorrect.");
                return;
            }
            string explanation = Userods.IsPasswordStrong(textPassword.Text);

            if (PrefC.GetBool(PrefName.PasswordsMustBeStrong))
            {
                if (explanation != "")
                {
                    MessageBox.Show(explanation);
                    return;
                }
            }
            //If the PasswordsMustBeStrong preference is off, still store whether or not the password is strong in case the preference is turned on later
            PasswordIsStrong = string.IsNullOrEmpty(explanation);
            if (textPassword.Text == "")
            {
                HashedResult = "";
            }
            else
            {
                HashedResult = Userods.HashPassword(textPassword.Text);
            }
            PasswordTyped = textPassword.Text;           //update the stored typed password for middle tier refresh
            //MessageBox.Show(hashedResult);
            DialogResult = DialogResult.OK;
        }
Esempio n. 6
0
        private void butOK_Click(object sender, EventArgs e)
        {
            bool shouldUpdateUserWeb = false;
            bool shouldPrint         = false;

            if (textOnlineUsername.ReadOnly == false)
            {
                if (textOnlineUsername.Text == "")
                {
                    MsgBox.Show(this, "Online Username cannot be blank.");
                    return;
                }
                else if (_userWebCur.UserName != textOnlineUsername.Text)
                {
                    if (UserWebs.UserNameExists(textOnlineUsername.Text, UserWebFKeyType.PatientPortal))
                    {
                        MsgBox.Show(this, "The Online Username already exists.");
                        return;
                    }
                    _userWebCur.UserName = textOnlineUsername.Text;
                    shouldUpdateUserWeb  = true;
                    if (!_wasPrinted)
                    {
                        shouldPrint = true;
                    }
                }
            }
            if (textOnlinePassword.Text != "" && textOnlinePassword.Text != "********")
            {
                string error = Patients.IsPortalPasswordValid(textOnlinePassword.Text);
                if (error != "")               //Non-empty string means it was invalid.
                {
                    MessageBox.Show(this, error);
                    return;
                }
                if (!_wasPrinted)
                {
                    shouldPrint = true;
                }
                shouldUpdateUserWeb  = true;
                _userWebCur.Password = Userods.HashPassword(textOnlinePassword.Text, false);
            }
            if (shouldPrint)
            {
                DialogResult result = MessageBox.Show(Lan.g(this, "Online Username or Password changed but was not printed, would you like to print?")
                                                      , Lan.g(this, "Print Patient Info")
                                                      , MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    //Print the showing information.
                    PrintPatientInfo();
                }
                else if (result == DialogResult.No)
                {
                    //User does not want to print.  Do nothing.
                }
                else if (result == DialogResult.Cancel)
                {
                    return;
                }
            }
            if (shouldUpdateUserWeb)
            {
                UserWebs.Update(_userWebCur, _userWebOld);
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 7
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            bool   usingEcw     = Programs.UsingEcwTightOrFullMode();
            Userod selectedUser = null;

            if (PrefC.GetBool(PrefName.UserNameManualEntry))
            {
                for (int i = 0; i < listUser.Items.Count; i++)
                {
                    //Check the user name typed in using ToLower and Trim because Open Dental is case insensitive and does not allow white-space in regards to user names.
                    if (textUser.Text.Trim().ToLower() == listUser.Items[i].ToString().Trim().ToLower())
                    {
                        selectedUser = (Userod)listUser.Items[i];                      //Found the typed username
                        break;
                    }
                }
                if (selectedUser == null)
                {
                    MsgBox.Show(this, "Login failed");
                    return;
                }
            }
            else
            {
                selectedUser = (Userod)listUser.SelectedItem;
            }
            string password = textPassword.Text;

            if (usingEcw)             //ecw requires hash, but non-ecw requires actual password
            {
                password = Userods.HashPassword(password, true);
            }
            if (selectedUser.UserName == "Stay Open" && IsSimpleSwitch && PrefC.IsODHQ)
            {
                // No need to check password when changing task users at HQ to user "Stay Open".
            }
            else
            {
                try {
                    Userods.CheckUserAndPassword(selectedUser.UserName, password, usingEcw);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "")
            {
                MsgBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                return;
            }
            //successful login.
            if (!IsSimpleSwitch)
            {
                Security.CurUser        = selectedUser.Copy();
                Security.IsUserLoggedIn = true;
                //Jason approved always storing the cleartext password that the user typed in
                //since this is necessary for Reporting Servers over middle tier and was already happening when a user logged in over middle tier.
                Security.PasswordTyped = password;
                if (PrefC.GetBool(PrefName.PasswordsMustBeStrong) && PrefC.GetBool(PrefName.PasswordsWeakChangeToStrong))
                {
                    if (Userods.IsPasswordStrong(textPassword.Text) != "")                   //Password is not strong
                    {
                        MsgBox.Show(this, "You must change your password to a strong password due to the current Security settings.");
                        FormOpenDental FormOD = Application.OpenForms.OfType <FormOpenDental>().ToList()[0]; //There always should be exactly 1.
                        if (!FormOD.ChangePassword(true))                                                    //Failed password update.
                        {
                            return;
                        }
                    }
                }
            }
            else
            {
                CurUserSimpleSwitch = selectedUser.Copy();
            }
            if (!IsSimpleSwitch)
            {
                SecurityLogs.MakeLogEntry(Permissions.UserLogOnOff, 0, "User: "******" has logged on.");
            }
            Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end");
            DialogResult = DialogResult.OK;
        }
Esempio n. 8
0
        private void butLogin_Click(object sender, EventArgs e)
        {
            Userod userEntered;
            string password;

            try {
                bool useEcwAlgorithm = Programs.UsingEcwTightOrFullMode();
                //ecw requires hash, but non-ecw requires actual password
                password = textPassword.Text;
                if (useEcwAlgorithm)
                {
                    //Userods.HashPassword explicitly goes over to middle tier in order to use it's MD5 algorithm.
                    //It doesn't matter what Security.CurUser is when it is null because we are technically trying to set it for the first time.
                    //It cannot be null before invoking HashPassword because middle needs it to NOT be null when creating the credentials for DtoGetString.
                    if (Security.CurUser == null)
                    {
                        Security.CurUser = new Userod();
                    }
                    password = Userods.HashPassword(password, true);
                }
                string username = textUser.Text;
                                #if DEBUG
                if (username == "")
                {
                    username = "******";
                    password = "******";
                }
                                #endif
                userEntered = Userods.CheckUserAndPassword(username, password, useEcwAlgorithm);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            //successful login.
            Security.CurUser              = userEntered;
            Security.PasswordTyped        = password;
            Security.IsUserLoggedIn       = true;
            RemotingClient.HasLoginFailed = false;
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb &&
                string.IsNullOrEmpty(userEntered.Password) &&
                string.IsNullOrEmpty(textPassword.Text))
            {
                MsgBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                FormOpenDental FormOD = Application.OpenForms.OfType <FormOpenDental>().ToList()[0]; //There always should be exactly 1.
                if (!FormOD.ChangePassword(true))                                                    //Failed password update.
                {
                    return;
                }
            }
            if (PrefC.GetBool(PrefName.PasswordsMustBeStrong) &&
                PrefC.GetBool(PrefName.PasswordsWeakChangeToStrong) &&
                Userods.IsPasswordStrong(textPassword.Text) != "")                  //Password is not strong
            {
                MsgBox.Show(this, "You must change your password to a strong password due to the current Security settings.");
                FormOpenDental FormOD = Application.OpenForms.OfType <FormOpenDental>().ToList()[0]; //There always should be exactly 1.
                if (!FormOD.ChangePassword(true))                                                    //Failed password update.
                {
                    return;
                }
            }
            SecurityLogs.MakeLogEntry(Permissions.UserLogOnOff, 0, "User: "******" has logged on.");
            DialogResult = DialogResult.OK;
        }
Esempio n. 9
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textFirstName.Text == "")
            {
                MsgBox.Show(this, "Please fill in a first name.");
                return;
            }
            if (textLastName.Text == "")
            {
                MsgBox.Show(this, "Please fill in a last name.");
                return;
            }
            if (textAbbr.Text == "")
            {
                MsgBox.Show(this, "Please fill in an abbreviation.");
                return;
            }
            if (textUserName.Text == "")
            {
                MsgBox.Show(this, "Please fill in a user name.");
                return;
            }
            ProvStudent.FName          = textFirstName.Text;
            ProvStudent.LName          = textLastName.Text;
            ProvStudent.Abbr           = textAbbr.Text;
            ProvStudent.SchoolClassNum = _listSchoolClasses[comboClass.SelectedIndex].SchoolClassNum;
            Userod newUser        = new Userod();
            bool   isAutoUserName = true;

            if (!ProvStudent.IsNew || _autoUserName.ToString() != textUserName.Text)
            {
                isAutoUserName = false;
            }
            if (isAutoUserName && !PrefC.GetBool(PrefName.RandomPrimaryKeys))             //Is a new student using the default user name given
            {
                long provNum = Providers.GetNextAvailableProvNum();
                if (_autoUserName != provNum)
                {
                    MsgBox.Show(this, "The default user name was already taken.  The next available user name was used.");
                    _autoUserName = provNum;
                }
                provNum = Providers.Insert(ProvStudent);
                if (provNum != _autoUserName)
                {
                    MsgBox.Show(this, "The default user name is unavailable.  Please set a user name manually.");
                    Providers.Delete(ProvStudent);
                    return;
                }
                newUser.UserName = _autoUserName.ToString();
                newUser.Password = Userods.HashPassword(textPassword.Text);
                newUser.ProvNum  = provNum;
                Userods.Insert(newUser, new List <long> {
                    PrefC.GetLong(PrefName.SecurityGroupForStudents)
                });
            }
            else              //Has changed the user name from the default or is editing a pre-existing student
            {
                try {
                    if (ProvStudent.IsNew)
                    {
                        long provNum = Providers.Insert(ProvStudent);
                        newUser.UserName = textUserName.Text;
                        newUser.Password = textPassword.Text;
                        newUser.ProvNum  = provNum;
                        Userods.Insert(newUser, new List <long> {
                            PrefC.GetLong(PrefName.SecurityGroupForStudents)
                        });                                                                                                                 //Performs validation
                    }
                    else
                    {
                        Providers.Update(ProvStudent);
                        _existingUser.UserName = textUserName.Text;
                        if (textPassword.Text != "")
                        {
                            _existingUser.Password = Userods.HashPassword(textPassword.Text);
                        }
                        Userods.Update(_existingUser);                        //Performs validation
                    }
                }
                catch (Exception ex) {
                    if (ProvStudent.IsNew)
                    {
                        Providers.Delete(ProvStudent);
                    }
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            DialogResult = DialogResult.OK;
        }