mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Fix two Passphrase credential type issues
Summary: Fixes T4991. Two issues: - These error messages pass an object to "%s", when they mean to pass a type constant. - The check for noncreatable credentials is incorrectly in the "edit" branch of the controller. Test Plan: - Edited a "SSH Key on disk" credential. - Tried to create a credential with a bogus type. Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T4991 Differential Revision: https://secure.phabricator.com/D9299
This commit is contained in:
parent
b7a8c0b200
commit
b93c2f6852
1 changed files with 19 additions and 13 deletions
|
@ -26,23 +26,18 @@ final class PassphraseCredentialEditController extends PassphraseController {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = PassphraseCredentialType::getTypeByConstant(
|
$type = $this->getCredentialType($credential->getCredentialType());
|
||||||
$credential->getCredentialType());
|
|
||||||
if (!$type) {
|
|
||||||
throw new Exception(pht('Credential has invalid type "%s"!', $type));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$type->isCreateable()) {
|
|
||||||
throw new Exception(
|
|
||||||
pht('Credential has noncreateable type "%s"!', $type));
|
|
||||||
}
|
|
||||||
|
|
||||||
$is_new = false;
|
$is_new = false;
|
||||||
} else {
|
} else {
|
||||||
$type_const = $request->getStr('type');
|
$type_const = $request->getStr('type');
|
||||||
$type = PassphraseCredentialType::getTypeByConstant($type_const);
|
$type = $this->getCredentialType($type_const);
|
||||||
if (!$type) {
|
|
||||||
return new Aphront404Response();
|
if (!$type->isCreateable()) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Credential has noncreateable type "%s"!',
|
||||||
|
$credential->getCredentialType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$credential = PassphraseCredential::initializeNewCredential($viewer)
|
$credential = PassphraseCredential::initializeNewCredential($viewer)
|
||||||
|
@ -358,4 +353,15 @@ final class PassphraseCredentialEditController extends PassphraseController {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getCredentialType($type_const) {
|
||||||
|
$type = PassphraseCredentialType::getTypeByConstant($type_const);
|
||||||
|
|
||||||
|
if (!$type) {
|
||||||
|
throw new Exception(
|
||||||
|
pht('Credential has invalid type "%s"!', $type_const));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue