Example #1
0
        private void NewUser()
        {
            UserDialogue userDialog = new UserDialogue();

            userDialog.Text                 = "New User";
            userDialog.userTextBox.Text     = "";
            userDialog.userTextBox.Enabled  = true;
            userDialog.passwordTextBox.Text = "";
            userDialog.ShowDialog();
            if (userDialog.DialogResult == DialogResult.OK)
            {
                if (userDialog.userTextBox.Text != "")
                {
                    bool add = true;
                    foreach (User u in userList.Items)
                    {
                        if (userDialog.userTextBox.Text == u.Username)
                        {
                            MessageBox.Show("Username: \"" + u.Username + "\" already taken.");
                            add = false;
                            break;
                        }
                    }
                    if (add)
                    {
                        User u2 = new User(userDialog.userTextBox.Text);
                        if (ServerOptions.UseStrongPasswords)
                        {
                            if (Authenticator.IsStrongPassword(u2, userDialog.passwordTextBox.Text))
                            {
                                u2.Password = PasswordHashUtility.HashPassword(userDialog.passwordTextBox.Text);

                                userList.Items.Add(u2);
                            }
                            else
                            {
                                MessageBox.Show(passwordRulesString);
                            }
                        }
                        else
                        {
                            u2.Password = PasswordHashUtility.HashPassword(userDialog.passwordTextBox.Text);

                            userList.Items.Add(u2);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Username");
                }
            }
            SetButtons();
        }
Example #2
0
        private void EditUser()
        {
            User selected = (User)userList.SelectedItem;

            UserDialogue userDialog = new UserDialogue();

            userDialog.Text                = "Edit User";
            userDialog.userTextBox.Text    = selected.Username;
            userDialog.userTextBox.Enabled = false;
            string oldPassword = selected.Password;

            userDialog.passwordTextBox.Text = oldPassword;
            userDialog.ShowDialog();

            if (userDialog.DialogResult == DialogResult.OK)
            {
                if (userDialog.passwordTextBox.Text == oldPassword)
                {
                    // do nothing
                }
                else if (ServerOptions.UseStrongPasswords)
                {
                    if (Authenticator.IsStrongPassword(selected, userDialog.passwordTextBox.Text))
                    {
                        selected.Password = PasswordHashUtility.HashPassword(userDialog.passwordTextBox.Text);
                    }
                    else
                    {
                        MessageBox.Show(passwordRulesString);
                    }
                }
                else
                {
                    selected.Password = PasswordHashUtility.HashPassword(userDialog.passwordTextBox.Text);
                }
            }
            SetButtons();
            //ud.Show();
        }
Example #3
0
        private void EditUser()
        {
            User selected = (User)userList.SelectedItem;

            UserDialogue userDialog = new UserDialogue();
            userDialog.Text = "Edit User";
            userDialog.userTextBox.Text = selected.Username;
            userDialog.userTextBox.Enabled = false;
            string oldPassword = selected.Password;
            userDialog.passwordTextBox.Text = oldPassword;
            userDialog.ShowDialog();

            if (userDialog.DialogResult == DialogResult.OK)
            {
                if (userDialog.passwordTextBox.Text == oldPassword)
                {
                    // do nothing
                }
                else if (ServerOptions.UseStrongPasswords)
                {
                    if (Authenticator.IsStrongPassword(selected, userDialog.passwordTextBox.Text))
                    {
                        selected.Password = PasswordHashUtility.HashPassword(userDialog.passwordTextBox.Text);

                    }
                    else
                    {
                        MessageBox.Show(passwordRulesString);
                    }
                }
                else
                {
                    selected.Password = PasswordHashUtility.HashPassword(userDialog.passwordTextBox.Text);                    
                }

            }
            SetButtons();
            //ud.Show();
        }
Example #4
0
        private void NewUser()
        {
            UserDialogue userDialog = new UserDialogue();
            userDialog.Text = "New User";
            userDialog.userTextBox.Text = "";
            userDialog.userTextBox.Enabled = true;
            userDialog.passwordTextBox.Text = "";
            userDialog.ShowDialog();
            if (userDialog.DialogResult == DialogResult.OK)
            {
                if (userDialog.userTextBox.Text != "")
                {
                    bool add = true;
                    foreach (User u in userList.Items)
                    {
                        if (userDialog.userTextBox.Text == u.Username)
                        {
                            MessageBox.Show("Username: \"" + u.Username + "\" already taken.");
                            add = false;
                            break;
                        }
                    }
                    if (add)
                    {
                        User u2 = new User(userDialog.userTextBox.Text);
                        if (ServerOptions.UseStrongPasswords)
                        {

                            if (Authenticator.IsStrongPassword(u2, userDialog.passwordTextBox.Text))
                            {
                                u2.Password = PasswordHashUtility.HashPassword(userDialog.passwordTextBox.Text);

                                userList.Items.Add(u2);

                            }
                            else
                            {
                                MessageBox.Show(passwordRulesString);
                            }
                        }
                        else
                        {
                            u2.Password = PasswordHashUtility.HashPassword(userDialog.passwordTextBox.Text);
                            
                            userList.Items.Add(u2);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Username");
                }

            }
            SetButtons();
        }