The US president has praised the Hungarian leader for his hardline approach to immigration and nationalist policies.