Esempio n. 1
0
        /**
         * When the login button is selected. Checks the field for correctness
         * then checks db for whether that user exists or not
         * */
        private void logInButton_Click(object sender, EventArgs e)
        {
            if (logInUsername.Text.Length < 1)
            {
                MessageBox.Show("No Username Specified!");
            }
            else if (logInPassword.Text.Length < 1)
            {
                MessageBox.Show("No Password Specified!");
            }
            else   // Check for user
            {
                HashAlgorithm hash     = new SHA256Managed();
                byte[]        passHash = hash.ComputeHash(Encoding.UTF8.GetBytes(logInPassword.Text));
                String        password = Convert.ToBase64String(passHash);
                if (db.checkUserInDB(logInUsername.Text, password))
                {
                    //MessageBox.Show("Yay, you're in!");
                    if (db.isUserAdmin(logInUsername.Text))
                    {
                        mainMenu mm = new mainMenu(this, logInUsername.Text.ToString());
                        mm.Show();
                    }
                    else
                    {
                        mainMenuUser umm = new mainMenuUser(this, logInUsername.Text.ToString());
                        umm.Show();
                    }

                    this.Hide();
                    logInUsername.Text = "";
                    logInPassword.Text = "";
                }
                else
                {
                    MessageBox.Show("That Username/Password combination is not in the database!");
                }
            }
        }
Esempio n. 2
0
 /**
  * Gives the viewLesson the mmUser form
  * */
 public void getUserForm(mainMenuUser mmUser)
 {
     userMM = mmUser;
 }