Ejemplo n.º 1
0
        private void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            //Open new database connection
            SqlConnection connection = new SqlConnection(this.connectionString);

            database.DatabaseConnection newConnection = new database.DatabaseConnection(connection.ConnectionString);
            connection.Open();

            //Command to get the actual answered security question
            string email = this.encryption.HashTextSHA256(this.emailTextBox.Text.ToUpper().Trim());

            if (util.RegexUtilities.IsValidPassword(this.newPasswordBox.Password) &&
                this.newPasswordBox.Password == this.confirmNewPasswordBox.Password)
            {
                SqlCommand changePassword = new SqlCommand("UPDATE [USER] SET Password = @Password WHERE Email=@Email", connection);
                //Fill the parameter of the query
                changePassword.Parameters.AddWithValue("@Email", email);
                changePassword.Parameters.AddWithValue("@Password", this.encryption.HashUniqueTextSHA256(this.confirmNewPasswordBox.Password));
                changePassword.ExecuteNonQuery();

                MessageBox.Show("Password Changed", "Success", MessageBoxButton.OK, MessageBoxImage.Information);

                LoginWindow             loginWindow    = new LoginWindow();
                function.WindowSettings windowSettings = new function.WindowSettings();

                windowSettings.TransitionScreen(loginWindow, this);
            }
        }
Ejemplo n.º 2
0
        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            LoginWindow loginWindow = new LoginWindow();

            function.WindowSettings windowSettings = new function.WindowSettings();

            windowSettings.TransitionScreen(loginWindow, this);
        }
Ejemplo n.º 3
0
        private void ConfirmSecurityAnswer_Click(object sender, RoutedEventArgs e)
        {
            try {
                if (SystemSettings.IsInternetAvailable() == true)
                {
                    //Open new database connection
                    SqlConnection      connection    = new SqlConnection(this.connectionString);
                    DatabaseConnection newConnection = new DatabaseConnection(connection.ConnectionString);
                    connection.Open();

                    string email = this.encryption.HashTextSHA256(this.emailTextBox.Text);

                    //Set the answer returned by the query to a variable for comparison
                    string answer = newConnection.GetSecurityQuestionAnswer(email);

                    if (this.encryption.HashTextSHA256(this.securityQuestionAnswerTextBox.Text) == answer)
                    {
                        this.newPasswordLabel.Opacity         = 100;
                        this.newPasswordLabel.Visibility      = Visibility.Visible;
                        this.newPasswordBox.Opacity           = 100;
                        this.newPasswordBox.Visibility        = Visibility.Visible;
                        this.confirmNewPasswordBox.Opacity    = 100;
                        this.confirmNewPasswordBox.Visibility = Visibility.Visible;
                        this.confirmPasswordLabel.Opacity     = 100;
                        this.confirmPasswordLabel.Visibility  = Visibility.Visible;
                        this.newPasswordLabel.Focus();

                        this.securityQuestionAnswerTextBox.IsReadOnly = true;
                        this.securityQuestionAnswerTextBox.Background = Brushes.SlateGray;
                        this.confirmSecurityAnswerButton.Visibility   = Visibility.Collapsed;
                        this.doneButton.Opacity    = 100;
                        this.doneButton.Visibility = Visibility.Visible;
                        this.newPasswordBox.Focus();
                    }
                    else
                    {
                        this.count--;
                        MessageBox.Show($"The answer entered is incorrect. You have {this.count} attempts left.", "Incorrect Answer", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        this.securityQuestionAnswerTextBox.Clear();
                        this.securityQuestionAnswerTextBox.Focus();
                    }

                    if (this.count == 0)
                    {
                        LoginWindow             loginWindow    = new LoginWindow();
                        function.WindowSettings windowSettings = new function.WindowSettings();

                        windowSettings.TransitionScreen(loginWindow, this);
                    }
                    connection.Close();
                }
            } catch (SqlException) {
                MessageBox.Show("An SQL Exception was caught!");
            }
        }