示例#1
0
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            PassHash hash = new PassHash();
            string   password;

            password = textBox2.Text;
            hash.EncodePasswordToBase64(password);
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("Please fill all the required fields.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (!isUsernameValid(textBox1.Text))
                {
                    MessageBox.Show("Invalid username. Username must contain 3 - 16 characters", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (!isPasswordValid(textBox2.Text))
                {
                    MessageBox.Show("Invalid password. Password must contain 8 - 16 characters.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    PassHash hash = new PassHash();
                    string   encryptedPass;
                    encryptedPass = hash.EncodePasswordToBase64(textBox2.Text);

                    Request req = new Request();
                    if (req.loginPost(textBox1.Text, encryptedPass))
                    {
                        User.nickname = textBox1.Text.ToString();
                        this.Hide();
                        Menu menu = new Draw4Fun___client.Menu();
                        menu.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Wrong username or password.", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
示例#3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text) ||
                string.IsNullOrEmpty(textBox3.Text) || !checkBox1.Checked)
            {
                MessageBox.Show("Please fill all the required fields.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (!isUsernameValid(textBox1.Text))
                {
                    MessageBox.Show("Invalid username. Username must contain 3 - 16 characters", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (!isPasswordValid(textBox2.Text))
                {
                    MessageBox.Show("Invalid password. Password must contain 8 - 16 characters.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (!isPasswordEqual(textBox2.Text, textBox3.Text))
                {
                    MessageBox.Show("Passwords are not equal.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    PassHash hash = new PassHash();
                    string   encryptedPass;
                    encryptedPass = hash.EncodePasswordToBase64(textBox3.Text);

                    Request req = new Request();
                    req.registerPost(textBox1.Text.ToLower(), encryptedPass);

                    MessageReport msg = new MessageReport("Successfully registered.");
                    msg.Show();
                    this.Close();
                }
            }
        }