Ian Madigan kicked 13 points Leinster as took advantage of leaders Munster's defeat at the Scarlets with a thrilling 28-25 win over Glasgow.