public async Task <JsonWebToken> LoginByRefreshToken(string refreshToken, int userId)
        {
            var isTokeValid = await _refreshTokenProvider.ValidateRefreshTokenAsync(userId, refreshToken);

            if (!isTokeValid)
            {
                throw new UnauthorizedException(userId);
            }

            var token = await _jwtProvider.GenerateAccessAndRefreshTokenAsync(userId, refreshToken);

            if (token == null)
            {
                throw new UnauthorizedException(userId);
            }

            return(token);
        }
        public async Task <JsonWebToken> Handle(LoginByRefreshTokenCommand request, CancellationToken cancellationToken)
        {
            var isTokeValid = await _refreshTokenProvider.ValidateRefreshTokenAsync(request.UserId, request.RefreshToken);

            if (!isTokeValid)
            {
                throw new UnauthorizedException("Unauthorized", $"User with id: {request.UserId} has been unauthorized");
            }

            var token = await _jwtProvider.GenerateAccessAndRefreshTokenAsync(request.UserId, request.RefreshToken);

            if (token == null)
            {
                throw new UnauthorizedException("Unauthorized", $"User with id: {request.UserId} has been unauthorized");
            }

            return(token);
        }