private void butOK_Click(object sender, EventArgs e)
 {
     if (!_isCreate && !IsInSecurityWindow)
     {
         string userPassCur = Userods.GetUserByName(textUserName.Text, false).Password;
         //If user's current password is blank we dont care what they put for the old one.
         if (userPassCur != "" && Userods.HashPassword(textCurrent.Text) != userPassCur)
         {
             MessageBox.Show(this, "Current password incorrect.");
             return;
         }
     }
     if (textPassword.Text == "")
     {
         MessageBox.Show(this, "Passwords cannot be blank.");
         return;
     }
     else
     {
         HashedResult = Userods.HashPassword(textPassword.Text);
         if (Userods.GetUserByName(textUserName.Text, false).UserName == Security.CurUser.UserName || IsInSecurityWindow)
         {
             Security.PasswordTyped = textPassword.Text;
             //They're updating the password for the logged in user.  Update CurUser for when they sync then attempt to log into remote DB.
         }
     }
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            Userod selectedUser = null;

            if (IsMiddleTierSync)
            {
                selectedUser           = new Userod();
                selectedUser.UserName  = textUser.Text;
                selectedUser.Password  = Userods.HashPassword(textPassword.Text);
                Security.CurUser       = selectedUser;
                Security.PasswordTyped = textPassword.Text;
            }
            else
            {
                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)
                    {
                        MessageBox.Show(this, "Login failed");
                        return;
                    }
                }
                else
                {
                    selectedUser = (Userod)listUser.SelectedItem;
                }
                try {
                    Userods.CheckUserAndPassword(selectedUser.UserName, textPassword.Text, false);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
                if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "")
                {
                    MessageBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                    return;
                }
                Security.CurUser       = selectedUser.Copy();
                Security.PasswordTyped = textPassword.Text;
            }
            //if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){//Not sure we need this when connecting to CEMT, but not sure enough to delete.
            //	string password=textPassword.Text;
            //	if(Programs.UsingEcwTightOrFullMode()) {//ecw requires hash, but non-ecw requires actual password
            //		password=Userods.EncryptPassword(password,true);
            //	}
            //	Security.PasswordTyped=password;
            //}
            DialogResult = DialogResult.OK;
        }
 private void butOK_Click(object sender, EventArgs e)
 {
     if (PrefC.GetString(PrefName.CentralManagerPassHash) != Userods.HashPassword(textPassword.Text))
     {
         MessageBox.Show("Bad password.");
         return;
     }
     DialogResult = DialogResult.OK;
 }
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textAccessCode.Text != "I'm admin")
     {
         MessageBox.Show("Access code is incorrect.");
         return;
     }
     Prefs.UpdateString(PrefName.CentralManagerPassHash, Userods.HashPassword(textPassword.Text));
     Prefs.RefreshCache();
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 5
0
 public static void CreateUnitTestUser()
 {
     if (Userods.GetUserByName(UnitTestUserName, false) == null)
     {
         Userod newUser = new Userod()
         {
             UserName = UnitTestUserName,
             Password = Userods.HashPassword(UnitTestPassword),
         };
         try {
             Userods.Insert(newUser, new List <long> {
                 1
             });
             Userods.RefreshCache();
         }
         catch (Exception e) {
             throw new Exception("Unable to create the default Unit Test user.", e);
         }
     }
 }