mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 18:22:41 +01:00
Show more information about OAuth tokens in the Account Settings -> External Accounts screen
Summary: Ref T1536. - Allow providers to customize the look of external accounts. - For username/password auth, don't show the account view (it's confusing and not useful). - For OAuth accounts, show token status. Test Plan: {F47374} {F47375} Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Maniphest Tasks: T1536 Differential Revision: https://secure.phabricator.com/D6289
This commit is contained in:
parent
f8ed6422f8
commit
e826842179
4 changed files with 56 additions and 12 deletions
|
@ -320,4 +320,22 @@ abstract class PhabricatorAuthProvider {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function willRenderLinkedAccount(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
PhabricatorObjectItemView $item,
|
||||||
|
PhabricatorExternalAccount $account) {
|
||||||
|
|
||||||
|
$account_view = id(new PhabricatorAuthAccountView())
|
||||||
|
->setExternalAccount($account)
|
||||||
|
->setAuthProvider($this);
|
||||||
|
|
||||||
|
$item->appendChild(
|
||||||
|
phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'mmr mml mst mmb',
|
||||||
|
),
|
||||||
|
$account_view));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,4 +343,34 @@ abstract class PhabricatorAuthProviderOAuth extends PhabricatorAuthProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function willRenderLinkedAccount(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
PhabricatorObjectItemView $item,
|
||||||
|
PhabricatorExternalAccount $account) {
|
||||||
|
|
||||||
|
// Get a valid token, possibly refreshing it.
|
||||||
|
$oauth_token = $this->getOAuthAccessToken($account);
|
||||||
|
|
||||||
|
$item->addAttribute(pht('OAuth2 Account'));
|
||||||
|
|
||||||
|
if ($oauth_token) {
|
||||||
|
$oauth_expires = $account->getProperty('oauth.token.access.expires');
|
||||||
|
if ($oauth_expires) {
|
||||||
|
$item->addAttribute(
|
||||||
|
pht(
|
||||||
|
'Active OAuth Token (Expires: %s)',
|
||||||
|
phabricator_datetime($oauth_expires, $viewer)));
|
||||||
|
} else {
|
||||||
|
$item->addAttribute(
|
||||||
|
pht(
|
||||||
|
'Active OAuth Token'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$item->addAttribute(pht('No OAuth Access Token'));
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::willRenderLinkedAccount($viewer, $item, $account);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,4 +239,11 @@ final class PhabricatorAuthProviderPassword
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function willRenderLinkedAccount(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
PhabricatorObjectItemView $item,
|
||||||
|
PhabricatorExternalAccount $account) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,21 +77,10 @@ final class PhabricatorSettingsPanelExternalAccounts
|
||||||
->setDisabled(!$can_unlink)
|
->setDisabled(!$can_unlink)
|
||||||
->setHref('/auth/unlink/'.$account->getProviderKey().'/'));
|
->setHref('/auth/unlink/'.$account->getProviderKey().'/'));
|
||||||
|
|
||||||
$account_view = id(new PhabricatorAuthAccountView())
|
|
||||||
->setExternalAccount($account);
|
|
||||||
|
|
||||||
if ($provider) {
|
if ($provider) {
|
||||||
$account_view->setAuthProvider($provider);
|
$provider->willRenderLinkedAccount($viewer, $item, $account);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->appendChild(
|
|
||||||
phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'mmr mml mst mmb',
|
|
||||||
),
|
|
||||||
$account_view));
|
|
||||||
|
|
||||||
$linked->addItem($item);
|
$linked->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue