示例#1
0
        private User CreateUser(RegistrationRequest registrationRequest, HashedPasswordData hashedPassword)
        {
            User user = Mapper.Map <User>(registrationRequest);

            user.HashedPassword = hashedPassword.HashedPassword;
            user.PasswordSalt   = hashedPassword.PasswordSalt;

            _userModifier.CreateUser(user);
            return(user);
        }
示例#2
0
        public static HashedPasswordData CreateHashedPassword(string password)
        {
            HashedPasswordData hashedPasswordData = new HashedPasswordData();

            using (var hmac = new System.Security.Cryptography.HMACSHA512())
            {
                hashedPasswordData.PasswordSalt   = hmac.Key;
                hashedPasswordData.HashedPassword = hmac.ComputeHash(Encoding.UTF8.GetBytes(password));
            }

            return(hashedPasswordData);
        }
示例#3
0
        public UserDto RegisterNewUser(RegistrationRequest registrationRequest, out RegistrationStatus registrationStatus)
        {
            registrationStatus = ValidateRegistration(registrationRequest);

            if (registrationStatus != RegistrationStatus.SUCCESS)
            {
                return(null);
            }

            HashedPasswordData hashedPassword = PasswordHashComputer.CreateHashedPassword(registrationRequest.Password);
            User user = CreateUser(registrationRequest, hashedPassword);

            return(Mapper.Map <UserDto>(user));
        }