Example #1
0
        public Client(string key)
        {
            var requester = new Requester(key);

            CreateAuthUri          = new CreateAuthUri(requester);
            GetOobConfirmationCode = new GetOobConfirmationCode(requester);
            ResetPassword          = new ResetPassword(requester);
            SetAccountInfo         = new SetAccountInfo(requester);
            SignupNewUser          = new SignupNewUser(requester);
            VerifyPassword         = new VerifyPassword(requester);
        }
Example #2
0
        public void Verify()
        {
            var checker = new Mock <IRepository>();
            var verify  = new VerifyPassword();

            var passwordChecker = new PasswordCheckerService(checker.Object, verify);


            var(success, message) = passwordChecker.VerifyPassword("");

            Assert.AreEqual((false, " is empty "), (success, message));
        }
        public async Task VerifyPasswordReturnsTrueWhenPasswordIsContainsPoundSymbol()
        {
            // Arrange
            var password = "******";
            var salt = new byte[] { 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73 };
            var storedPasswordHash = PasswordHashFactory.Get(password, salt);

            var command = new VerifyPassword();

            // Act
            var result = await command.ExecuteAsync(new VerifyPasswordParameters(storedPasswordHash, password));

            // Assert
            Assert.IsTrue(result);
        }
        public async Task VerifyPasswordReturnsFalseWhenPasswordIsIncorrect()
        {
            // Arrange
            var password = "******";
            var salt = new byte[] { 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73 };
            var storedPasswordHash = PasswordHashFactory.Get(password, salt);

            var command = new VerifyPassword();

            // Act
            var result = await command.ExecuteAsync(new VerifyPasswordParameters(storedPasswordHash, "incorrect password"));

            // Assert
            Assert.IsFalse(result);
        }
        static void Main(string[] args)
        {
            string test1 = "12feet";
            string test2 = "pr;ctices";
            string test3 = "absolutely";
            string test4 = "abcdefghijklmnopq";
            bool Resolve;
            string resultMsg =null;
            VerifyPassword verifypassword = new VerifyPassword();
            Resolve = verifypassword.CheckPassword(test1,out resultMsg);
            Resolve = verifypassword.CheckPassword(test2, out resultMsg);
            Resolve = verifypassword.CheckPassword(test3, out resultMsg);
            Resolve = verifypassword.CheckPassword(test4, out resultMsg);
            Resolve = verifypassword.CheckPassword("design1234", out resultMsg);

        }
        private void SingIn(object param)
        {
            var passwordBox = param as PasswordBox;

            if (passwordBox == null)
            {
                return;
            }
            var password = passwordBox.Password;

            var manager = IdentityUser.Where(user => user.Email == _login && VerifyPassword.VerifyHashedPassword(user.PasswordHash, password)).FirstOrDefault();

            if (manager == null)
            {
                MessageBox.Show("Wrong login or password.", "Login error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
                return;
            }


            #region
            //var isRoleExist = AspNetUserRoles.Where(userRole => userRole.UserId == manager.UserId).FirstOrDefault();
            //if (isRoleExist == null)
            //{
            //    MessageBox.Show("You do not have access to the application.", "Login error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
            //    return;
            //}

            //var concreteRole = AspNetRoles.Where(role => role.UserId == isRoleExist.RoleId).FirstOrDefault();
            //if (concreteRole == null)
            //{
            //    MessageBox.Show("You do not have access to the application.", "Login error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
            //    return;
            //}
            #endregion

            ///<summary>
            ///if login is successful pass true
            ///</summary>
            ViewManager.GetInstance().ChangeViewModel(true);
        }
Example #7
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            User_Controller Controller = new User_Controller();

            if (Username.Text.Length == 0 && Password.Password.Length == 0 && VerifyPassword.Password.Length == 0)
            {
                UsernameErrorMessage.Text       = "Enter the valid username";
                PasswordErrorMessage.Text       = "You must enter password";
                VerifyPasswordErrorMessage.Text = "You must enter verify password";
                Username.Focus();
                Password.Focus();
                VerifyPassword.Focus();
            }
            else if (Username.Text.Length == 0 && Password.Password.Length == 0)
            {
                UsernameErrorMessage.Text = "Enter the valid username";
                PasswordErrorMessage.Text = "You must enter password";
                Username.Focus();
                Password.Focus();
            }
            else if (Username.Text.Length == 0 && VerifyPassword.Password.Length == 0)
            {
                UsernameErrorMessage.Text       = "Enter the valid username";
                VerifyPasswordErrorMessage.Text = "You must enter password";
                Username.Focus();
                VerifyPassword.Focus();
            }
            else if (Password.Password.Length == 0 && VerifyPassword.Password.Length == 0)
            {
                PasswordErrorMessage.Text       = "Enter the valid username";
                VerifyPasswordErrorMessage.Text = "You must enter password";
                Password.Focus();
                VerifyPassword.Focus();
            }
            else if (Username.Text.Length == 0)
            {
                UsernameErrorMessage.Text = "Enter the valid username";
                Username.Focus();
            }
            else if (Password.Password.Length == 0)
            {
                PasswordErrorMessage.Text = "You must enter password";
                Password.Focus();
            }
            else if (VerifyPassword.Password.Length == 0)
            {
                VerifyPasswordErrorMessage.Text = "You must enter verify password";
            }
            else if (Password.Password.Length != VerifyPassword.Password.Length)
            {
                VerifyPasswordErrorMessage.Text = "Verify password must be same with Password";
                VerifyPassword.Focus();
            }
            else
            {
                string username = Username.Text;
                string password = Password.Password;

                Controller.addUser(username, password);
                this.Hide();
                MainWindow main = new MainWindow();
                main.Show();
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            SqlCrud sql = new SqlCrud(GetConnectionString());
            GeneratePasswordAndSalt generatePasswordAndSalt = new GeneratePasswordAndSalt();
            SqlDataAccess           d = new SqlDataAccess();
            VerifyPassword          verifyValidPassword = new VerifyPassword();

            // Creates a user
            Users user = new Users();

            Console.Write("Enter First Name: ");
            user.FirstName = Console.ReadLine();

            Console.Write("Enter Last Name: ");
            user.LastName = Console.ReadLine();


            Console.Write("Enter a password: "******"password and salt:   {Convert.ToBase64String(passwordAndSalt)}");
            Console.WriteLine("Type yoy password again to login");
            string testPassword = Console.ReadLine();
            Console.WriteLine(
                verifyValidPassword.VerifyVerySecurePassword(testPassword, UserSalt, 50000, passwordAndSalt));
            Console.ReadLine();

            #endregion



            //generatePasswordAndSalt.GeneratePassword(user);


            // Creates a user wit password user ans saves it to the database
            sql.CreateUserAndPassword(user);


            Users u = new Users();
            Console.Write("Enter a password To Verify Login: "******"Password: {u.Password} Salt: {u.Salt}");

            Console.WriteLine(verifyValidPassword.VerifyValidPassword(verifyPassword, user, u));


            Console.WriteLine("Hello World!");
        }