By most accounts , Obama did a masterful job aligning the promise of his candidacy with the grievances expressed by both blacks and whites , noting in particular how the anger of working-class whites over affirmative action and welfare formed the Reagan coalition .