/// <summary>
        /// Update password
        /// </summary>
        /// <param name="sender">userc control formProfil</param>
        /// <param name="e"></param>
        private void UpdatePass_Click(object sender, EventArgs e)
        {
            UcFormProfil UCFP = (UcFormProfil)sender;

            if (UpdateClick != null)
            {
                UpdateClick(this, e);
            }

            Person Person = new Person();

            Person = Controller.CheckAccess(_person.PersonFirstName, Convert.ToBase64String(EncodingPass.SalAndHash(UCFP.Pass.Text)));
            if (Person == null || Person.PersonId != _person.PersonId ||
                UCFP.textBoxNewPass1.Text != UCFP.textBoxNewPass2.Text ||
                UCFP.textBoxNewPass1.Text == Properties.Resources.EMPTY)
            {
                MessageBox.Show(Properties.Resources.BADPASSWORD, Properties.Resources.CAPTIONEMPTYFIELDS,
                                MessageBoxButtons.OK);
            }
            else
            {
                Controller.UpdatePassword(_person.PersonId,
                                          Convert.ToBase64String(EncodingPass.SalAndHash(UCFP.textBoxNewPass1.Text)));
            }
        }
Example #2
0
        public void Test_CheckAccess_ReturnPerson()
        {
            // Arrange
            string personLogin    = "******";
            string personPass     = Convert.ToBase64String(EncodingPass.SalAndHash("0000"));
            Person PersonExpected = new Person(1, "Jean", "Moderator", "*****@*****.**", personPass, 1);

            Controller.DAOInitialize("Data Source=176.31.248.137;Initial Catalog=user19;Persist Security Info=True;User ID=user19;Password=274user19");

            // Act
            Person PersonActual = Controller.CheckAccess(personLogin, personPass);

            // Assert
            Assert.AreEqual(PersonExpected, PersonActual);
        }
Example #3
0
 /// <summary>
 /// Check if the user exists in the db
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void Login_Click(object sender, EventArgs e)
 {
     if (UcLogin.textBoxLogin.Text.Length != 0 && UcLogin.textBoxPass.Text.Length != 0)
     {
         PersonConnected = new Person();
         PersonConnected = Controller.CheckAccess(UcLogin.textBoxLogin.Text.Trim(), Convert.ToBase64String(EncodingPass.SalAndHash(UcLogin.textBoxPass.Text)));
         if (PersonConnected == null)
         {
             MessageBox.Show(Properties.Resources.BADLOGIN, Properties.Resources.CAPTIONLOGIN, MessageBoxButtons.OK);
         }
         else
         {
             UcLogin.LoginTextBox.Clear();
             UcLogin.PassTextBox.Clear();
             UcLogin.Enabled = false;
             UcLogin.Visible = false;
             if (EventConnection != null)
             {
                 EventConnection(this, new PersonConnectedEventArgs {
                     PersonConnected = PersonConnected
                 });
             }
         }
     }
     else
     {
         MessageBox.Show(Properties.Resources.BADLOGIN, Properties.Resources.CAPTIONLOGIN, MessageBoxButtons.OK);
     }
 }