Beispiel #1
0
 // This Method allows the user to change username or password or both, the data is sent to a WCF
 // service that handles the information with a stored procedure
 private void UserChange(object sender, EventArgs e)
 {
     // First some controls...
     if (NewPasswordBox.Text == "" && NewPasswordBoxConfirm.Text == "" && NewUserBox.Text == "" && OldPasswordBox.Text == "")
     {
         MessageBox.Show("Are you sure you're in the right place?");
         NewPasswordBox.Focus();
     }
     // ... i check if the passwords match
     else if (NewPasswordBox.Text != NewPasswordBoxConfirm.Text)
     {
         MessageBox.Show("Passwords don't match");
         NewPasswordBox.Focus();
         return;
     }
     // Then i check if the boxes are empty and that the new password is secure enough
     else if (NewPasswordBox.Text != "" && NewPasswordBox.Text.Length < 6)
     {
         MessageBox.Show("You need a stronger password, 6 characters are enough");
         NewPasswordBox.Focus();
         return;
     }
     // Finally i execute the stored procedure
     if (OldPasswordBox.Text == null || (NewUserBox.Text == null && NewPasswordBox.Text == null))
     {
         return;
     }
     try
     {
         // The passwords will be hashed trough EasyEncryption, via the MD5 protocol
         string OldHashedPassword = EasyEncryption.MD5.ComputeMD5Hash(OldPasswordBox.Text);
         string NewHashedPassword = "";
         if (NewPasswordBox.Text != "")
         {
             NewHashedPassword = EasyEncryption.MD5.ComputeMD5Hash(NewPasswordBox.Text);
         }
         // I send the data to the WCF Service
         try
         {
             WCF.UserPasswordChange(NewUserBox.Text, NewHashedPassword, CurrentUserBox.Text, OldHashedPassword);
             MessageBox.Show("Information changed!");
             if (NewUserBox.Text != "" && OldPasswordBox.Text != "")
             {
                 UsernameDisplayer.Text = NewUserBox.Text;
             }
         }
         catch (Exception WCFexception)
         {
             MessageBox.Show(WCFexception.ToString());
             throw;
         }
     }
     catch (Exception WCFexception2)
     {
         MessageBox.Show(WCFexception2.ToString());
         throw;
     }
 }
Beispiel #2
0
 private void FakeNewRepasswordBox_GotFocus(object sender, RoutedEventArgs e)
 {
     NewPasswordBox.Visibility     = System.Windows.Visibility.Visible;
     FakeNewPasswordBox.Visibility = System.Windows.Visibility.Collapsed;
     NewPasswordBox.Focus();
 }