public TokenDto AuthenicateUser(UserInComingDto userIncomingData) { User user = _unitOfWork.UserRepository.GetUser(userIncomingData.Email); bool userExist = user != default(User); bool passwordVerified = VerifyPasswordHash(userIncomingData.Password, user.PasswordHash, user.PasswordSalt); if (!userExist || !passwordVerified) { _logger.LogTrace($"A user with email {userIncomingData.Email} tride to login but failed."); throw new InvalidInputException("Email and/or password is incorrect"); } string token = _tokenHandler.CreateAuthenticationToken(user); TokenDto tokenDto = new TokenDto(); tokenDto.Token = token; return(tokenDto); }