Exemplo n.º 1
0
        public User CreateUser(
            string email,
            string password,
            DateTime dob,
            string city,
            string state,
            string country,
            string securityQ1,
            string securityQ1Answer,
            string securityQ2,
            string securityQ2Answer,
            string securityQ3,
            string securityQ3Answer)
        {
            new System.Net.Mail.MailAddress(email);

            DateTime today18YearsAgo = DateTime.Now.AddYears(-18);

            if (dob > today18YearsAgo)
            {
                throw new InvalidDobException("Date of birth less than 18 years ago");
            }

            if (!_passwordService.CheckPasswordLength(password))
            {
                throw new PasswordInvalidException("Password is too short");
            }

            int pwnedCount = _passwordService.CheckPasswordPwned(password);

            if (pwnedCount > 0)
            {
                throw new PasswordPwnedException("Password has been pwned");
            }

            byte[] salt = _passwordService.GenerateSalt();
            string hash = _passwordService.HashPassword(password, salt);

            User user = new User
            {
                Email        = email,
                PasswordHash = hash,
                PasswordSalt = salt,

                DateOfBirth = dob,
                City        = city,
                State       = state,
                Country     = country,

                SecurityQ1       = securityQ1,
                SecurityQ1Answer = securityQ1Answer,
                SecurityQ2       = securityQ2,
                SecurityQ2Answer = securityQ2Answer,
                SecurityQ3       = securityQ3,
                SecurityQ3Answer = securityQ3Answer,
                UpdatedAt        = DateTime.UtcNow,
                CreatedAt        = DateTime.UtcNow
            };

            return(_userService.CreateUser(user));
        }
Exemplo n.º 2
0
 public void CheckPasswordPwned()
 {
     Assert.AreNotEqual(0, ps.CheckPasswordPwned("password"));
     Assert.AreEqual(0, ps.CheckPasswordPwned("ASDfas!@fdasf!223gs3"));
 }
Exemplo n.º 3
0
 /// <summary>
 ///     This is not ready for review
 ///     Not part of our sprint 3
 /// </summary>
 /// <param name="password"></param>
 public void CheckPassword(string password)
 {
     IPasswordService _passwordService = new PasswordService();
     object           passwordResponse = _passwordService.CheckPasswordPwned(password);
 }