The court may determine the controversy as between the parties before it, if it can do so without prejudice to the rights of others; but, if a complete determination cannot be had without the presence of other parties, the court may direct that such other parties be brought in. If a person not a party has an interest or title which the judgment will affect, the court, on his application, shall direct him to be made a party.