If a convert to the Church who holds the Priesthood leaves the Church, has not had his temple endowments, leaves the Church, but lives a righteous life; what resurrection, if any, does that man qualify for? If a women, who has been baptised, but has not had her endowments, leaves the Church, but lives a clean life, how does the Lord view that? if they both rejoin the Church, what happens?
Simply put, each person will arrive at his or her destination at the end of their life’s road. In your examples, you have two different individuals who have said, “I will go this far in my faith journey, but no further.” These two, “who are not valiant in the testimony of Jesus” (D&C 76:79) receive the terrestrial glory (it would be the same if they were endowed but still stopped short their journey). Of course, I’m assuming you mean they were righteous in the way the world uses this word – they lived otherwise virtuous lives. If you mean righteous in the sense that they were truly following their Lord, their paths would inevitably lead them back to the temple, where they could make covenants to live a celestial law and merit celestial glory. If they were indeed on the way to life and salvation, that is exactly what they will find at the end of life’s journey (if their lives were cut short before they had the opportunity to receive temple ordinances, the vicarious work would be in their favor).