US president strikes triumphant tone in speech but faces legal setbacks and hurdles in Congress as midterms approach.