public async Task <JsonWebToken> LoginByCredentialsAsync(string email, string password)
        {
            if (email == null || password == null)
            {
                throw new UnauthorizedException(email);
            }

            var token = await _jwtProvider.GenerateAccessAndRefreshTokenAsync(email, password);

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

            return(token);
        }
        public async Task <JsonWebToken> Handle(LoginByCredentialsCommand request, CancellationToken cancellationToken)
        {
            var token = await _jwtProvider.GenerateAccessAndRefreshTokenAsync(request.Email, request.Password);

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

            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);
        }