mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-15 10:00:55 +01:00
(stable) Fix credential control logic for restricted credentials
Summary: Fixes T12975. This logic didn't deal with PolicyException correctly. Test Plan: {F5167549} Reviewers: chad Reviewed By: chad Maniphest Tasks: T12975 Differential Revision: https://secure.phabricator.com/D18537
This commit is contained in:
parent
007fb4c30e
commit
89a70bf56c
1 changed files with 20 additions and 14 deletions
|
@ -53,13 +53,22 @@ final class PassphraseCredentialControl extends AphrontFormControl {
|
||||||
if (strlen($current_phid) && empty($options_map[$current_phid])) {
|
if (strlen($current_phid) && empty($options_map[$current_phid])) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$current_name = null;
|
||||||
|
try {
|
||||||
$user_credential = id(new PassphraseCredentialQuery())
|
$user_credential = id(new PassphraseCredentialQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withPHIDs(array($current_phid))
|
->withPHIDs(array($current_phid))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$user_credential) {
|
|
||||||
|
if ($user_credential) {
|
||||||
|
$current_name = pht(
|
||||||
|
'%s %s',
|
||||||
|
$user_credential->getMonogram(),
|
||||||
|
$user_credential->getName());
|
||||||
|
}
|
||||||
|
} catch (PhabricatorPolicyException $policy_exception) {
|
||||||
// Pull the credential with the ominipotent viewer so we can look up
|
// Pull the credential with the ominipotent viewer so we can look up
|
||||||
// the ID and tell if it's restricted or invalid.
|
// the ID and provide the monogram.
|
||||||
$omnipotent_credential = id(new PassphraseCredentialQuery())
|
$omnipotent_credential = id(new PassphraseCredentialQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||||
->withPHIDs(array($current_phid))
|
->withPHIDs(array($current_phid))
|
||||||
|
@ -68,17 +77,14 @@ final class PassphraseCredentialControl extends AphrontFormControl {
|
||||||
$current_name = pht(
|
$current_name = pht(
|
||||||
'%s (Restricted Credential)',
|
'%s (Restricted Credential)',
|
||||||
$omnipotent_credential->getMonogram());
|
$omnipotent_credential->getMonogram());
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($current_name === null) {
|
||||||
$current_name = pht(
|
$current_name = pht(
|
||||||
'Invalid Credential ("%s")',
|
'Invalid Credential ("%s")',
|
||||||
$current_phid);
|
$current_phid);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$current_name = pht(
|
|
||||||
'%s %s',
|
|
||||||
$user_credential->getMonogram(),
|
|
||||||
$user_credential->getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
$options_map = array(
|
$options_map = array(
|
||||||
$current_phid => $current_name,
|
$current_phid => $current_name,
|
||||||
|
|
Loading…
Reference in a new issue