예제 #1
0
        public bool CreateUser(string userId, string password)
        {
            _logger.Debug("Creating user authentication for userId={0}", userId);

            var userCredentials = _authenticationRepository.Get(new Guid(userId));

            if (userCredentials != null)
            {
                var message = string.Format("User authentication exists for userId={0}", userId);
                _logger.Debug(message);
                throw new CustomException(message, UsersErrorCodes.UserDirectoryAccountExistsError);
            }

            _logger.Debug("No user authentication found for userId={0}", userId);

            var hash = _passwordHash.Generate(userId, password, SecretKey);

            _authenticationRepository.Save(new UserCredentials
            {
                EntityId     = new Guid(userId),
                PasswordHash = hash
            });

            _logger.Debug("Created user authentication for userId={0}", userId);

            return(true);
        }