Interaction logic for ConfirmPasswordWindow.xaml
Inheritance: System.Windows.Window
Exemple #1
0
        private void signin_click(object sender, RoutedEventArgs e)
        {
            ResetStatus();

            bool dataOK = true;

            dataOK = _validator.ValidateFieldMatches(Username, Username.Text, null,
                                                     "Username can only use normal characters", "", ".*[^a-zA-Z0-9_\\-\\.].*") && dataOK;
            dataOK = _validator.ValidateFieldMatches(Username, Username.Text, null,
                                                     "Username cannot contain spaces", "", ".* .*") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Email, Email.Text, null, "Please enter your email address") && _validator.ValidateEmail(Email, null) && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Location, Location.Text, null, "Please enter your location", "City, Country") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Password, Password.Password, null, "Please enter your password") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Username, Username.Text, null, "Please enter your preferred username") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Lastname, Lastname.Text, null, "Please enter your last name", "Last") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Firstname, Firstname.Text, null, "Please enter your first name", "First") && dataOK;


            if (dataOK)
            {
                if (_appContext.ConnectionManager.Connection.isEstablished())
                {
                    ClearBlurEffect(_dashboard);
                    ConfirmPasswordWindow confirmPasswordWindow = new ConfirmPasswordWindow();
                    GwupeClientAppContext.CurrentAppContext.UIManager.ShowDialog(confirmPasswordWindow);
                    if (!confirmPasswordWindow.Cancelled)
                    {
                        // OK, password will be changed
                        if (!confirmPasswordWindow.ConfirmPassword.Password.Equals(Password.Password))
                        {
                            Password.Background = new SolidColorBrush(Colors.MistyRose);
                            _validator.SetError("Passwords don't match");
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                    _appContext.LoginManager.Signup(Firstname.Text, Lastname.Text, Username.Text, Password.Password, Email.Text, Location.Text, Supporter.IsChecked != null && (bool)Supporter.IsChecked);
                }
                else
                {
                    _validator.SetError("Cannot sign up, Gwupe is not connected.");
                }
            }
        }
Exemple #2
0
        private void SaveChanges_Click(object sender, RoutedEventArgs e)
        {
            ResetStatus();

            bool dataOK = true;

            dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Email, Email.Text, EmailLabel, "Please enter your email address") && _uiHelper.Validator.ValidateEmail(Email, EmailLabel) && dataOK;
            dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Location, Location.Text, LocationLabel, "Please enter your location", "City, Country") && dataOK;
            if (PasswordChange != null && PasswordChange.IsChecked == true)
            {
                dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Password, Password.Password, PasswordLabel, "Please enter your password") && dataOK;
            }
            dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Lastname, Lastname.Text, NameLabel, "Please enter your last name", "Last") && dataOK;
            dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Firstname, Firstname.Text, NameLabel, "Please enter your first name", "First") && dataOK;

            if (dataOK)
            {
                if (_appContext.ConnectionManager.Connection.isEstablished())
                {
                    if (PasswordChange != null && PasswordChange.IsChecked == true)
                    {
                        var confirmPasswordWindow = new ConfirmPasswordWindow();
                        _appContext.UIManager.ShowDialog(confirmPasswordWindow);
                        if (!confirmPasswordWindow.Cancelled)
                        {
                            // OK, password will be changed
                            if (!confirmPasswordWindow.ConfirmPassword.Password.Equals(Password.Password))
                            {
                                Password.Background      = new SolidColorBrush(Colors.MistyRose);
                                PasswordLabel.Foreground = new SolidColorBrush(Colors.Red);
                                _uiHelper.Validator.SetError("Cannot save changes, passwords don't match");
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    ThreadPool.QueueUserWorkItem(state => _uiHelper.RunElevation("Saving", SaveCurrentUser, "save user"));
                }
            }
        }
Exemple #3
0
        private void SaveChanges_Click(object sender, RoutedEventArgs e)
        {
            ResetStatus();

            bool dataOK = true;
            dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Email, Email.Text, EmailLabel, "Please enter your email address") && _uiHelper.Validator.ValidateEmail(Email, EmailLabel) && dataOK;
            dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Location, Location.Text, LocationLabel, "Please enter your location", "City, Country") && dataOK;
            if (PasswordChange != null && PasswordChange.IsChecked == true)
            {
                dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Password, Password.Password, PasswordLabel, "Please enter your password") && dataOK;
            }
            dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Lastname, Lastname.Text, NameLabel, "Please enter your last name", "Last") && dataOK;
            dataOK = _uiHelper.Validator.ValidateFieldNonEmpty(Firstname, Firstname.Text, NameLabel, "Please enter your first name", "First") && dataOK;

            if (dataOK)
            {
                if (_appContext.ConnectionManager.Connection.isEstablished())
                {
                    if (PasswordChange != null && PasswordChange.IsChecked == true)
                    {
                        var confirmPasswordWindow = new ConfirmPasswordWindow();
                        _appContext.UIManager.ShowDialog(confirmPasswordWindow);
                        if (!confirmPasswordWindow.Cancelled)
                        {
                            // OK, password will be changed
                            if (!confirmPasswordWindow.ConfirmPassword.Password.Equals(Password.Password))
                            {
                                Password.Background = new SolidColorBrush(Colors.MistyRose);
                                PasswordLabel.Foreground = new SolidColorBrush(Colors.Red);
                                _uiHelper.Validator.SetError("Cannot save changes, passwords don't match");
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    ThreadPool.QueueUserWorkItem(state => _uiHelper.RunElevation("Saving", SaveCurrentUser, "save user"));
                }
            }
        }
Exemple #4
0
        private void signin_click(object sender, RoutedEventArgs e)
        {
            ResetStatus();

            bool dataOK = true;
            dataOK = _validator.ValidateFieldMatches(Username, Username.Text, null,
                                                    "Username can only use normal characters", "", ".*[^a-zA-Z0-9_\\-\\.].*") && dataOK;
            dataOK = _validator.ValidateFieldMatches(Username, Username.Text, null,
                                                    "Username cannot contain spaces", "", ".* .*") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Email, Email.Text, null, "Please enter your email address") && _validator.ValidateEmail(Email, null) && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Location, Location.Text, null, "Please enter your location", "City, Country") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Password, Password.Password, null, "Please enter your password") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Username, Username.Text, null, "Please enter your preferred username") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Lastname, Lastname.Text, null, "Please enter your last name", "Last") && dataOK;
            dataOK = _validator.ValidateFieldNonEmpty(Firstname, Firstname.Text, null, "Please enter your first name", "First") && dataOK;

            if (dataOK)
            {
                if (_appContext.ConnectionManager.Connection.isEstablished())
                {
                    ClearBlurEffect(_dashboard);
                    ConfirmPasswordWindow confirmPasswordWindow = new ConfirmPasswordWindow();
                    GwupeClientAppContext.CurrentAppContext.UIManager.ShowDialog(confirmPasswordWindow);
                    if (!confirmPasswordWindow.Cancelled)
                    {
                        // OK, password will be changed
                        if (!confirmPasswordWindow.ConfirmPassword.Password.Equals(Password.Password))
                        {
                            Password.Background = new SolidColorBrush(Colors.MistyRose);
                            _validator.SetError("Passwords don't match");
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                    _appContext.LoginManager.Signup(Firstname.Text, Lastname.Text, Username.Text, Password.Password, Email.Text, Location.Text, Supporter.IsChecked != null && (bool)Supporter.IsChecked);
                }
                else
                {
                    _validator.SetError("Cannot sign up, Gwupe is not connected.");
                }
            }
        }