Example #1
0
        private void SignIn()
        {
            string login;
            var    newUser = new UserForm(NewUsername.Text, NewPassword.Password);
            var    res     = SqlDataAccess.RegisterUser(newUser, out login);

            if (res == -1)
            {
                MessageBox.Show("Введенное имя пользователя уже существует", "Ошибка ввода логина", MessageBoxButton.OK, MessageBoxImage.Error);
                NewUsername.Clear();
                NewPassword.Clear();
            }
            else
            {
                RegPrivileges.ChangeElementsForUser(login,
                                                    (TextBlock)Owner.FindName("UserLogin"),
                                                    (Button)Owner.FindName("Autorization"),
                                                    (Button)Owner.FindName("SignOut"),
                                                    (Button)Owner.FindName("ExcelExport"),
                                                    (Grid)Owner.FindName("GridClothes"),
                                                    (Grid)Owner.FindName("GridCalendar"),
                                                    (Grid)Owner.FindName("GridPaint"));

                MessageBox.Show("Пользователь добавлен!", "", MessageBoxButton.OK, MessageBoxImage.Information);
                Owner.Activate();
                Close();
            }
        }
Example #2
0
 public void SuccessfullPasswordChange()
 {
     NavigateTo();
     OldPassword.Clear();
     OldPassword.SendKeys("1234");
     NewPassword.Clear();
     NewPassword.SendKeys("123456");
     ConfirmPassword.Clear();
     ConfirmPassword.SendKeys("123456");
     ChangePasswordButton.Click();
 }
Example #3
0
 public void EnterMissmatchingNewPassword()
 {
     NavigateTo();
     OldPassword.Clear();
     OldPassword.SendKeys("1234");
     NewPassword.Clear();
     NewPassword.SendKeys("123456");
     ConfirmPassword.Clear();
     ConfirmPassword.SendKeys("12345");
     ChangePasswordButton.Click();
 }
Example #4
0
 public void EnterIncorrectCurrentPasswordChange()
 {
     NavigateTo();
     OldPassword.Clear();
     OldPassword.SendKeys("12345");
     NewPassword.Clear();
     NewPassword.SendKeys("123456");
     ConfirmPassword.Clear();
     ConfirmPassword.SendKeys("123456");
     ChangePasswordButton.Click();
 }
        //changing the value of an item will require sql fix
        private void Savebtn_Click(object sender, RoutedEventArgs e)
        {
            EditPopup.Visibility  = Visibility.Hidden;
            Conn.ConnectionString = LoginSystem.constring;
            Conn.Open();
            NpgsqlCommand iQuery = new NpgsqlCommand(String.Format("UPDATE passvault SET companyname = \'{0}\', passoword = \'{1}\' WHERE companyname =\'{2}\' and passoword=\'{3}\'; ", NewWebsite.Text, NewPassword.Text, precomname, prepass), Conn);

            iQuery.ExecuteNonQuery();
            Viewer.Items.Remove(Viewer.SelectedItem);
            Viewer.Items.Add(NewWebsite.Text + " " + NewPassword.Text);
            NewWebsite.Clear();
            NewPassword.Clear();
            Conn.Close();
        }
Example #6
0
 private void PasswordChange_Click_1(object sender, RoutedEventArgs e)
 {
     if (OldPassword.Password != Oldpassword)
     {
         MessageBox.Show("Incorrect Old Password. Please try again",
                         "Password Info", MessageBoxButton.OK, MessageBoxImage.Information);
         OldPassword.Clear();
         NewPassword.Clear();
         OldPassword.Focus();
         return;
     }
     if (PasswordChangeEvent != null)
     {
         PasswordChangeEvent(this, new PasswordChangeEventArgs(NewPassword.Password));
     }
 }
Example #7
0
 private void PasswordChange_Click_1(object sender, RoutedEventArgs e)
 {
     if (OldPassword.Password != ((User)UserSelector.SelectedItem).Password)
     {
         MessageBox.Show("Incorrect Old Password. Please try again",
                         "Password Info", MessageBoxButton.OK, MessageBoxImage.Information);
         OldPassword.Clear();
         NewPassword.Clear();
         OldPassword.Focus();
         return;
     }
     if (PasswordChangeEvent != null)
     {
         User u = ((User)UserSelector.SelectedItem);
         PasswordChangeEvent(this, new PasswordChangeEventArgs(new User(u.Name, NewPassword.Password)));
     }
 }
Example #8
0
        public async Task SaveAsync()
        {
            var hashedNewPassword    = NewPassword.HashValue();
            var hashedRepeatPassword = RepeatPassword.HashValue();

            if (!hashedNewPassword.Equals(hashedRepeatPassword))
            {
                IMainWindowViewModel.MessageQueue.Enqueue("The new password don't much with the repeated one.",
                                                          "OK",
                                                          (obj) => { },
                                                          new object(),
                                                          false,
                                                          true,
                                                          TimeSpan.FromSeconds(6));

                return;
            }

            var result = await IMainWindowViewModel.User.TryChangePasswordAsync(IMainWindowViewModel.User.Email, CurrentPassword, hashedNewPassword);

            if (result)
            {
                IMainWindowViewModel.MessageQueue.Enqueue("Password has changed successfully.",
                                                          "OK",
                                                          (obj) => { },
                                                          new object(),
                                                          false,
                                                          true,
                                                          TimeSpan.FromSeconds(6));
            }
            else
            {
                IMainWindowViewModel.MessageQueue.Enqueue("The old password do not much to one of the records in the server.",
                                                          "OK",
                                                          (obj) => { },
                                                          new object(),
                                                          false,
                                                          true,
                                                          TimeSpan.FromSeconds(6));
            }

            CurrentPassword.Clear();
            NewPassword.Clear();
            RepeatPassword.Clear();
        }
        private void resetButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (checkBox.IsChecked == true)
                {
                    if (!string.IsNullOrWhiteSpace(resetUsername.Text) && !string.IsNullOrWhiteSpace(OldPassword.Password))
                    {
                        string oldPassword = OldPassword.Password.ToString();
                        string userToReset = resetUsername.Text.ToString();
                        string newPassword = NewPassword.Password.ToString();

                        SqlConnection Aconn = new SqlConnection();
                        Aconn.ConnectionString = ConfigurationManager.ConnectionStrings["Other"].ConnectionString;

                        string Newquery = "UPDATE UserTable SET [password]=@newPass WHERE [username]=@user AND [password]=@pass;";

                        SqlCommand cmd = new SqlCommand(Newquery, Aconn);
                        cmd.Parameters.AddWithValue("@newPass", newPassword);
                        cmd.Parameters.AddWithValue("@user", userToReset);
                        cmd.Parameters.AddWithValue("@pass", oldPassword);
                        Aconn.Open();
                        cmd.ExecuteNonQuery();
                        Aconn.Close();

                        OldPassword.Clear();
                        resetUsername.Clear();
                        NewPassword.Clear();
                        MessageBox.Show("Password Change successful");
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }
Example #10
0
        private async void SaveNewPassword()
        {
            SaveLabel.Focusable = true;
            SaveLabel.Focus();
            SaveLabel.Focusable = false;

            if (Password.IsEnabled)
            {
                this.Close();
            }

            var flag = true;

            if (NewPassword.Password.Equals(string.Empty))
            {
                flag = false;
                BadNewPassword.BorderBrush = Brushes.Red;
            }

            if (ConfirmPassword.Password.Equals(string.Empty))
            {
                flag = false;
                BadConfirmPassword.BorderBrush = Brushes.Red;
            }

            if (!flag)
            {
                BadLabel.Content    = "Заполните обязательные поля";
                BadLabel.Visibility = Visibility.Visible;
                return;
            }

            if (NewPassword.Password != ConfirmPassword.Password)
            {
                NewPassword.Clear();
                ConfirmPassword.Clear();
                NewPassword.Focus();
                BadLabel.Content    = "Пароли не совпадают";
                BadLabel.Visibility = Visibility.Visible;
                return;
            }

            if (NewPassword.Password == Password.Password)
            {
                NewPassword.Clear();
                ConfirmPassword.Clear();
                NewPassword.Focus();
                BadLabel.Content    = "Пароль уже используется";
                BadLabel.Visibility = Visibility.Visible;
                return;
            }

            //rep.EditPass(NewPassword.Password);
            rep.GetPass = GlobalVars.GetHashCode(NewPassword.Password);
            // EncDecHelper.SetPassword(NewPassword.Password);


            await this.ShowMessageAsync(string.Empty, "Password has changed.");

            this.Close();
        }
Example #11
0
 private void Clear()
 {
     OldPassword.Clear();
     NewPassword.Clear();
     RepeatPassword.Clear();
 }