It is narrated from the Prophet of Islam (PBUH) who told Imam Ali (AS):
O’ Ali, whatever you do not like for yourself, do not like for others; and vice-versa. In this case you will be just in your judgement and you will be impartial in your justice, and the residents of the sky will like you, and you will be liked in the hearts of the residents of the earth. With God’s Will Protect my recommendation [1]. Of course the Prophet’s advice is for all the Muslims and must be obeyed at all the times till the end of the time. In another narration the first Shia Imam, Ali ibn Abitaleb (AS) said: Whatever you like for yourself, like it also for the people; in order to be a Muslim [2].
[1] Tohaful Oqool, Page 14.
[2] Qorarul Hikam, Page 113.
Source: en.shafaqna.com