Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Console.WriteLine(this.textBox1.Text);
            Console.WriteLine(this.textBox2.Text);

            LocalStore.currentUser = DatabaseAPI.SelectUser(this.textBox1.Text);
            if (LocalStore.currentUser == null)
            {
                Console.WriteLine("Invalid username.");
                label3.Text        = "Invalid username!";
                this.textBox1.Text = "";
                this.textBox2.Text = "";
            }
            else
            {
                label3.Text = "";
                string hashedPassword = sha256(this.textBox2.Text);
                if (LocalStore.currentUser.Password == hashedPassword)
                {
                    FormStorer.Add("Dashboard", new Dashboard());
                    FormStorer.Get("Login").Visible = false;
                    ((Dashboard)FormStorer.Get("Dashboard")).SetCurrentUser();
                    FormStorer.Get("Dashboard").Visible = true;
                }
                else
                {
                    Console.WriteLine("Invalid password.");
                    label3.Text        = "Invalid password!";
                    this.textBox1.Text = "";
                    this.textBox2.Text = "";
                }
            }
        }