Exemple #1
0
        private void butOK_Click(object sender, EventArgs e)
        {
            Userod user = Userods.GetUserByName(textUserName.Text, false);

            if (!_isCreate && !IsInSecurityWindow)
            {
                string userPassCur = "";
                if (user != null)
                {
                    userPassCur = user.PasswordHash;
                }
                //If user's current password is blank we dont care what they put for the old one.
                if (userPassCur != "" && !Authentication.CheckPassword(user, textCurrent.Text))
                {
                    MessageBox.Show(this, "Current password incorrect.");
                    return;
                }
            }
            if (textPassword.Text == "")
            {
                MessageBox.Show(this, "Passwords cannot be blank.");
                return;
            }
            else
            {
                LoginDetails = Authentication.GenerateLoginDetailsSHA512(textPassword.Text);
                if (user?.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;
        }
 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;
 }
Exemple #3
0
 public static void CreateAndSetUnitTestUser()
 {
     CreateUnitTestUser();
     //Get the Admin user, should always exist
     Security.CurUser       = Userods.GetUserByName(UnitTestUserName, false);
     Security.PasswordTyped = UnitTestPassword;          //For middle tier unit tests.
 }
Exemple #4
0
 public static void CreateUnitTestUser()
 {
     if (Userods.GetUserByName(UnitTestUserName, false) == null)
     {
         UserodT.CreateUser(UnitTestUserName, UnitTestPassword, new List <long> {
             1
         });
     }
 }
Exemple #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);
         }
     }
 }
Exemple #6
0
        public static void Initialize(TestContext context)
        {
            if (!UnitTestsCore.DatabaseTools.SetDbConnection("unittest", "localhost", "3306", "root", "", false))        //Put this in a config file in the future.
            {
                UnitTestsCore.DatabaseTools.SetDbConnection("", "localhost", "3306", "root", "", false);
                DatabaseTools.FreshFromDump("localhost", "3306", "root", "", false);            //this also sets database to be unittest.
            }
            else
            {
                //Clear the database before running the unittests (instead of after) for two reasons
                //1- if the cleanup is done using [TestCleanup], the cleanup will not be run if the user cancels in the middle of a test while debugging
                //2- if a test fails, we may want to look at the data in the db to see why it failed.
                UnitTestsCore.DatabaseTools.ClearDb();
            }
#if !DEBUG
            throw new Exception("You're running tests in release. BAD!!!");
#endif
            CreateUnitTestUser();
            //Get the Admin user, should always exist
            Security.CurUser       = Userods.GetUserByName(UnitTestUserName, false);
            Security.PasswordTyped = UnitTestPassword;          //For middle tier unit tests.
            //Uncomment the next line in order to run every single unit test method like it is using the middle tier.
            //RunTestsAgainstMiddleTier();
        }