Bereisheet (Genesis): Vayeishev > Ch 39
G-d helps Joseph in Egypt and Joseph becomes an overseer of Potiphar’s household
Joseph had been brought down to Egypt as a slave. Potiphar, Pharaoh's chamberlain, chief of the slaughterers, purchased him. The Lord was with Joseph, and he was a successful man, whatever Joseph did the Lord made prosper in his hand. Potiphar appointed Joseph over his house, and all he had he gave into his hand. The Lord blessed the house of the Egyptian for Joseph's sake.
Potiphar’s wife desires Joseph and sets him up to be imprisoned for his refusal
Joseph had handsome features and a beautiful complexion, so Potiphar’s wife desired him, but Joseph refused, saying to her “How can I commit this great evil, and sin against G-d?" One day when no one was around she grabbed him by his garment, saying, "Lie with me!" But he left his garment in her hand and ran out. Potiphar’s wife claimed that Joseph had come to desire her and showed his garment as proof. Potiphar believed her and put Joseph in prison.
G-d helps Joseph in prison and Joseph becomes an overseer of all other prisoners
The Lord was with Joseph, and He extended charisma to him, and He gave him favor in the eyes of the warden of the prison. So the warden of the prison delivered all the prisoners who were in the prison into Joseph's hand.
sin against G-d
Note that the Sin is against G-d!