The Prophet of Allah ﷺ forbade us from facing the qiblah while urinating, yet I saw him a year before he passed away facing it.
حدثنا محمد بن بشار حدثنا وهب بن جرير حدثنا أبي قال سمعت محمد بن إسحق يحدث عن أبان بن صالح عن مجاهد
نهى نبي الله ﷺ أن نستقبل القبلة ببول فرأيته قبل أن يقبض بعام يستقبلها
[Its isnad is hasan] Tirmidhi transmitted it, in Purification, chapter on what has been narrated as a concession regarding that, and Ibn Majah, no. 325, from Muhammad bin Bashshar with this wording. Tirmidhi said, "Hasan gharib," and Ibn Khuzayma graded it sahih, no. 58, as did Ibn Hibban (Mawarid), 134, and Hakim, 1/154, and Dhahabi agreed with him.