예제 #1
0
        public async Task <User> CreateUser(Registration registration)
        {
            _userValidator.ValidatePassword(registration.Password);

            var passwordHash = _passwordGuard.GeneratePasswordHash(registration.Password);

            var user = new User(
                UserLevel.User,
                registration.FirstName,
                registration.LastName,
                registration.Email.ToLower(),
                registration.BirthDate,
                DateTime.UtcNow,
                passwordHash);

            _userValidator.Validate(user);

            await _userRepository.Insert(user);

            return(user.WithoutPasswordHash());
        }
예제 #2
0
        public void ValidatePasswordTest()
        {
            //Arrange
            var password = "******";

            //Act
            var result = _validator.ValidatePassword(password);

            //Assert
            Assert.True(result);
        }
예제 #3
0
 public bool ValidateUser(string username, string password)
 {
     if (_userValidator.ValidatePassword(password) == false)
     {
         AddError = "Password length\nshould have\nminimum 6 letters";
         NotifyOfPropertyChange(() => AddError);
         return(false);
     }
     if (_userValidator.ValidateUsername(username) == false)
     {
         AddError = "Username taken or\ntoo short\n(min 3 letters)";
         NotifyOfPropertyChange(() => AddError);
         return(false);
     }
     else
     {
         return(true);
     }
 }