XWIKI-9474: HTML code in the console when logging-in from a subwiki.

* Refactored a bit the XWikiAuthServiceImpl#authenticate method.
* The "invalidcredentials" message was wrongly sent.