This is one way in which Joseph is is a man of Light.
Here he is working in a home of a very wealthy man. Joseph sticks to his work, and is highly respected but really loved by his boss, Potipher. His boss' attention seems to be totally focused on Joseph.
"Shortly after" Potiphera, is also clearly aware of Joseph as a sexual being. She sees where her husband's attention is going. It is out of pure lust that she is going after Joseph, pure Love for her husband, Potipher.
This is a rediculous way to get attention, but there is a choice made here. I belive that in this choice, Joseph is a Tzaddik we are to only love for this playing along. Joseph represents the sfirot of Yesod (aligned with the genitals, reproductive organs)* for this reason. Not because he restrained himself from Potiphera's advances, but the choices he made in support of the Love between Potipher and Potiphera.
The commentators point out that obviously Joseph is stronger than Potiphera! Obviously, he didn't have to give his coat, which she uses to prove his desire to rape her. Joseph gave her the coat making allowance for this role playing.
There was an earlier coat was a gift from his father. One reason for this gift (which I do not necessarily believe, although it supports this train of thought and is a possible reason for why his father's face flashes before him as he makes this choice) is that Joseph is born from the womb of Rachel, the woman his father, Jacob, loved. Most of the his brothers are born of Leah, his aunt, who lived in longing for Jacob. Perhaps the recognition of yearning in Potiphera is what incited compassion in Joseph. The sons of Leah had ripped the coat from him as well in acting out this jealousy when they almost killed Joseph. The rage at being the favored one had caused him to lose many a coat. In losing these coats, he is exposed for what his love is really about: his giving, not the egoic love of his boss or father.
Anyone who has ever been loved knows also how to move aside for a bigger Love Story for All of All of And All Of.
Joseph takes off that coat! and as the game of this goes, he winds up in jail under the charges of raping Potipher's wife. It continues like any game.
This incident incites Potipher's jealousy. He wakes up to his wife's love when Potiphera's sexuality gets enforced and acknoledged by Joseph.
Such is the beauty of supporting each other in love. It is said that Potipher and Potiphera's daughter marries Joseph, "Asenath daughter of Potiphera Chief of On" now named. Certainly no animocity, even though they once threw him in jail. Certainly a new knowing of Only Love.
*Sfirot see any book on Kabbalah