コード例 #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string userId        = tbLogin.Text;                                                     //get userID from textBox
            string passwordLogin = tbPasswordLogin.Text;                                             //get password from textBox

            User user1 = userRepo.GetUser(userId);                                                   //Get user details based on inputted userID

            bool result = pwdManager.IsPasswordMatch(passwordLogin, user1.Salt, user1.PasswordHash); //check if inputted password is matched with the password saved for this User

            if (result == true)
            {                                                        //if password is matched
                lstOutput.Items.Add("Test User Login Successfully"); //Display on listBox
            }
            else
            {                                                  //if password is incorrect
                lstOutput.Items.Add("Test User Login Failed"); //Display on listBox
            }

            tbLogin.Clear();
            tbPasswordLogin.Clear();
        }
コード例 #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string userId   = tbName.Text;
            string password = tbPassword.Text;

            User loginAdmin = userRepo.GetUser(userId);                                                   //get userID

            bool result = pwdManager.IsPasswordMatch(password, loginAdmin.Salt, loginAdmin.PasswordHash); //check if inputted password is matched with the password saved for this User

            if (result == true)                                                                           //if password matched
            {
                MessageBox.Show("Password matched! Server has been logon");
                new MultiFormContext(new ServerForm(), new ClientForm()); //serverform and clientform popup
            }
            else //if password is incorrect
            {
                MessageBox.Show("Incorrect Password! Please try again!");
            }
        }