Ejemplo n.º 1
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            ProjectManagementDatabaseClassesDataContext db = new ProjectManagementDatabaseClassesDataContext();

            var crypto = new SimpleCrypto.PBKDF2();

            string password = passwordTextBox.Text;

            string userName = userNameTextBox.Text;

            var result = db.getCurrentUser(userName);

            string salt     = "";
            string userType = "";

            if (result != null)
            {
                foreach (var sResult in result)
                {
                    salt     = sResult.PasswordSalt;
                    userType = sResult.UserType;

                    Console.WriteLine("UserType: " + userType);
                }



                string hashedPassword = crypto.Compute(password, salt);
                int    valid          = con.tryLogin(userName, hashedPassword, userType);

                if (valid == 1)
                {
                    this.Hide();
                }
                else
                {
                    Console.WriteLine("Wrong username or password");
                }
            }
        }