public async Task Register(User user, string password) { //check also email var isExist = await _uow.UserRepository.IsUserExist(user.UserName); if (isExist) { throw new AuthenticationException($"Username {user.UserName} is already taken"); } var salt = _encrypter.GenerateRandomSalt(); user.PasswordHash = _encrypter.GetHash(password, salt); user.PasswordSalt = salt; await _uow.UserRepository.Add(user); }