Block Sprinting to left and to right

Hi,
What i want to ask is if somebody knew how i could make my player not be able to sprint Backwards,to the left or to the right.

Herer’s my code

    public bool isSprinting;
    public bool isWalking;
    public bool InAir;
    public float WalkingSpeed = 6.0f;
    public float SprintingSpeed = 10.0f;
    public float JumpSpeed = 8.0f;
    public float Gravity = 20.0f;
    public AudioClip JumpSound;
    public Vector3 moveDir = Vector3.zero;


    private float timer = 0.0f;
    float bobbingSpeed = 0.18f;
    float bobbingAmount = 0.2f;
    float midpoint = 2.0f;
    void Update()
    {
        CharacterController controller = GetComponent<CharacterController>(); //Set the character Controller
        isSprinting = Input.GetButton("Sprint"); //If Pressing the Sprint Key Sprint
        if (controller.isGrounded)//If the Player is on the Ground
        {
            InAir = false;
            moveDir = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));//Get the axis for the direction
            moveDir = transform.TransformDirection(moveDir);//Move in the direction that we want

            if (Input.GetButton("Jump"))
            {
                InAir = true;
                isSprinting = false;
                isWalking = false;
                moveDir.y = JumpSpeed; //If we press the jump key accelerate the player on the Y axis
                this.audio.PlayOneShot(JumpSound);
            }
            if (moveDir != Vector3.zero)
            {
                isWalking = true;
            }
            else
            {
                isWalking = false;
            }
            if (isSprinting)
            {
                moveDir *= SprintingSpeed;//If we are sprinting set our speed to be equal to the sprinting speed
            }
            else
            {
                moveDir *= WalkingSpeed;//If we are not sprinting set our speed to be equal to the walking speed
            }
        }
        moveDir.y -= Gravity * Time.deltaTime;//Make gravity affect the player
        controller.Move(moveDir * Time.deltaTime);
    }

}

The following is an expansion of line 42 which checks that the moveDir and transform’s forward are within 45 degrees of each other. You can change the angle to constrict or relax how forward the player must be moving.

if(isSprinting&&Vector3.Angle(transform.forward, moveDir)<45f) {