Ejemplo n.º 1
0
        public void ChangedPassWordDoesNotMatch()
        {
            var passWord       = "******";
            var hashedPassword = PasswordHasher.SetPassword(passWord);
            var passWordHashed = PasswordHasher.DoesPasswordMatch("thisisanotherpassword", hashedPassword);

            Assert.False(passWordHashed);
        }
Ejemplo n.º 2
0
        public void HashedPassWordMatches()
        {
            var passWord       = "******";
            var hashedPassword = PasswordHasher.SetPassword(passWord);
            var passWordHashed = PasswordHasher.DoesPasswordMatch(passWord, hashedPassword);

            Assert.True(passWordHashed);
        }
Ejemplo n.º 3
0
        public void UpdateUserPasswordInDatabase(int id, PutValidateUser validate)
        {
            var sqlResult     = _userRepository.GetSingleUser(id);
            var validPassword = PasswordHasher.DoesPasswordMatch(validate.OldPassWord, sqlResult.PassWord);

            if (!validPassword)
            {
                throw new ArgumentException("Password provided is not valid so won't take action");
            }

            var newlyHashedPassword = PasswordHasher.SetPassword(validate.NewPassWord);

            sqlResult.PassWord = newlyHashedPassword;

            _userRepository.Update(sqlResult);
        }
Ejemplo n.º 4
0
        public bool CheckIfPassWordIsCorrect(ValidateUserModel validate)
        {
            var userFromDatabase = GetIdFromEmailOrUsername(validate);

            return(PasswordHasher.DoesPasswordMatch(validate.PassWord, userFromDatabase.PassWord));
        }