コード例 #1
0
 private void ButtonLogin_Click(object sender, EventArgs e)
 {
     if (!(textBoxEmail.Text == "Email") && !(textBoxPassword.Text == "Password"))
     {
         var controller           = new UserController();
         FacultyUserModel faculty = controller.ValidateLogin(textBoxEmail.Text, textBoxPassword.Text);
         if (faculty == null)
         {
             textBoxPassword.Clear();
             textBoxPassword.Focus();
         }
         else
         {
             //MessageBox.Show("Login successful.\nID: " + faculty.Id + "\nName: " + faculty.FullName + "\nEmail: " + faculty.Email);
             var dash = new FormDashboard(faculty);
             dash.FormClosed += new FormClosedEventHandler(dash_FormClosed);
             dash.Show();
             this.Hide();
         }
     }
     else
     {
         MessageBox.Show("Please insert your login credentials first");
     }
 }
コード例 #2
0
        private void ButtonBack_Click(object sender, EventArgs e)
        {
            var dash = new FormDashboard(faculty);

            dash.FormClosed += new FormClosedEventHandler(dash_FormClosed);
            dash.Show();
            this.Hide();
        }
コード例 #3
0
        private void labelTitle_Click(object sender, System.EventArgs e)
        {
            var dash = new FormDashboard(faculty);

            dash.FormClosed += new FormClosedEventHandler(dash_FormClosed);
            dash.Show();
            this.Hide();
        }
コード例 #4
0
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            if (!(textBoxEmail.Text == "Email") && !(textBoxPassword.Text == "Password") && !(string.IsNullOrWhiteSpace(textBoxEmail.Text)) && !(string.IsNullOrWhiteSpace(textBoxPassword.Text)))
            {
                LoadingForm loadingForm = new LoadingForm();
                loadingForm.Show();

                loadingForm.Step(20);
                var           controller = new UserController();
                Argon2Hashing hashing    = new Argon2Hashing();
                try
                {
                    FacultyUserModel faculty = controller.GetByEmail(textBoxEmail.Text);
                    if (faculty == null)
                    {
                        textBoxPassword.Clear();
                        textBoxPassword.Focus();
                    }
                    else
                    {
                        //Console.WriteLine("Got hash: " + faculty.Password);
                        //Console.WriteLine("Got salt: " + faculty.salt);
                        //Console.WriteLine("Verification: " + hashing.VerifyHash(textBoxPassword.Text, Convert.FromBase64String(faculty.salt), Convert.FromBase64String(faculty.Password)));
                        loadingForm.Step(20);
                        if (hashing.VerifyHash(textBoxPassword.Text, Convert.FromBase64String(faculty.salt), Convert.FromBase64String(faculty.Password)))
                        {
                            loadingForm.Step(60);
                            loadingForm.Close();
                            var dash = new FormDashboard(faculty);
                            dash.FormClosed += new FormClosedEventHandler(dash_FormClosed);
                            dash.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Incorrect email or password. Please try again");
                        }
                    }
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                loadingForm.Close();
            }
            else
            {
                MessageBox.Show("Please insert your login credentials first");
            }
        }