wordpress-mobile/WordPress-iOS — pull request #2758 by koke (2014-11-11 13:04:56+00:00)
Title: Fixes a crash when Jetpack authentication fails

For reasons I can't remember or understand, when the OAuth2 request
failed, we would still create the account as if nothing happened. The
code would even overwrite a perfectly valid account with wrong
credentials, leaving the app in a bad state.

The simplest way would be to just call `failure` if the OAuth2 request
failed, but some times, the first API request might succeed and the
OAuth2 request fails. In those cases, if we already have a WordPress.com
account which matches the one we're trying to add, we reuse that one,
but not try to replace password or auth token.

In fact, if there's already a valid account we shouldn't even call
OAuth2 to get a new token. But this is a hotfix for 3.6, and the whole
Jetpack authentication flow is going to change very soon anyway.

Fixes #2748