3 final class PhabricatorAuthFactorProviderDuoCredentialTransaction
4 extends PhabricatorAuthFactorProviderTransactionType
{
6 const TRANSACTIONTYPE
= 'duo.credential';
8 public function generateOldValue($object) {
9 $key = PhabricatorDuoAuthFactor
::PROP_CREDENTIAL
;
10 return $object->getAuthFactorProviderProperty($key);
13 public function applyInternalEffects($object, $value) {
14 $key = PhabricatorDuoAuthFactor
::PROP_CREDENTIAL
;
15 $object->setAuthFactorProviderProperty($key, $value);
18 public function getTitle() {
20 '%s changed the credential for this provider from %s to %s.',
21 $this->renderAuthor(),
22 $this->renderOldHandle(),
23 $this->renderNewHandle());
26 public function validateTransactions($object, array $xactions) {
27 $actor = $this->getActor();
30 if (!$this->isDuoProvider($object)) {
34 $old_value = $this->generateOldValue($object);
35 if ($this->isEmptyTextTransaction($old_value, $xactions)) {
36 $errors[] = $this->newRequiredError(
37 pht('Duo providers must have an API credential.'));
40 foreach ($xactions as $xaction) {
41 $new_value = $xaction->getNewValue();
43 if (!strlen($new_value)) {
47 if ($new_value === $old_value) {
51 $credential = id(new PassphraseCredentialQuery())
53 ->withIsDestroyed(false)
54 ->withPHIDs(array($new_value))
57 $errors[] = $this->newInvalidError(
59 'Credential ("%s") is not valid.',