1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Recover from a broken external OAuth2 account

Summary: Currently, the external accounts page can die in a fire if an OAuth2 link is bad. Instead of exploding, just fail the specific link.

Test Plan: Faked an error and got "invalid token" instead of an exception.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9937
This commit is contained in:
Evan Priestley 2014-07-15 13:39:56 -07:00
parent 1fc324066c
commit 7ac5abb979

View file

@ -239,8 +239,17 @@ abstract class PhabricatorAuthProviderOAuth2
PHUIObjectItemView $item, PHUIObjectItemView $item,
PhabricatorExternalAccount $account) { PhabricatorExternalAccount $account) {
// Get a valid token, possibly refreshing it. // Get a valid token, possibly refreshing it. If we're unable to refresh
$oauth_token = $this->getOAuthAccessToken($account); // it, render a message to that effect. The user may be able to repair the
// link by manually reconnecting.
$is_invalid = false;
try {
$oauth_token = $this->getOAuthAccessToken($account);
} catch (Exception $ex) {
$oauth_token = null;
$is_invalid = true;
}
$item->addAttribute(pht('OAuth2 Account')); $item->addAttribute(pht('OAuth2 Account'));
@ -256,6 +265,8 @@ abstract class PhabricatorAuthProviderOAuth2
pht( pht(
'Active OAuth Token')); 'Active OAuth Token'));
} }
} else if ($is_invalid) {
$item->addAttribute(pht('Invalid OAuth Access Token'));
} else { } else {
$item->addAttribute(pht('No OAuth Access Token')); $item->addAttribute(pht('No OAuth Access Token'));
} }