Пример #1
0
        public async Task AddClient(AddUserDto userDto)
        {
            var userFromDb = await _userRepository.GetUserByEmail(userDto.Email);

            if (userFromDb != null)
            {
                throw new Exception("Db contains this email ");
            }

            var hmac = new HMACSHA512();

            var newUser = new UserClient
            {
                Id           = Guid.NewGuid(),
                Email        = userDto.Email,
                PasswordSalt = hmac.Key,
                PasswordHash = hmac.ComputeHash(Encoding.ASCII.GetBytes(userDto.Password)),
                IsActive     = false
            };

            _emailSender.SendConfirmationEmain("Jan", "Kowalski", newUser.Email, newUser.Id);
            await _userRepository.AddUser(newUser);
        }
Пример #2
0
        public async Task AddClient(AddUserDto userDto)
        {
            var userFromDb = await _userRepository.GetUserByEmail(userDto.Email);

            if (userFromDb != null)
            {
                throw new Exception("Db contains this email ");
            }

            var hmac = new HMACSHA512();

            var newUser = new UserClient
            {
                Id           = Guid.NewGuid(),
                Email        = userDto.Email,
                FirstName    = userDto.FirstName,
                LastName     = userDto.LastName,
                PhoneNumber  = userDto.PhoneNumber,
                PasswordSalt = hmac.Key,
                PasswordHash = hmac.ComputeHash(Encoding.ASCII.GetBytes(userDto.Password))
            };

            await _userRepository.AddUser(newUser);
        }