Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //add friend
            Request req   = new Request();
            dynamic data2 = JsonConvert.DeserializeObject(jsonString);

            if (listBox1.SelectedIndex < 0)
            {
                MessageReport msg2 = new MessageReport("You must choose a friend.");
                msg2.Show();
            }
            else
            {
                friendId = data2[listBox1.SelectedIndex].id;
                req.addFriend(User.id, friendId);
                MessageReport msg = new MessageReport("Friend added.");
                msg.Show();
            }
        }
Ejemplo n.º 2
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();
                }
            }
        }