get a taste of your own medicine
Upper Intermediate (B2) informal
To have bad things done to you that you have done to others.
"After years of being rude to colleagues, he finally got a taste of his own medicine when his new boss treated him the same way."