@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 63 lines 1.6 kB view raw
1<?php 2 3final class PhabricatorAuthFactorProviderDuoHostnameTransaction 4 extends PhabricatorAuthFactorProviderTransactionType { 5 6 const TRANSACTIONTYPE = 'duo.hostname'; 7 8 public function generateOldValue($object) { 9 $key = PhabricatorDuoAuthFactor::PROP_HOSTNAME; 10 return $object->getAuthFactorProviderProperty($key); 11 } 12 13 public function applyInternalEffects($object, $value) { 14 $key = PhabricatorDuoAuthFactor::PROP_HOSTNAME; 15 $object->setAuthFactorProviderProperty($key, $value); 16 } 17 18 public function getTitle() { 19 return pht( 20 '%s changed the hostname for this provider from %s to %s.', 21 $this->renderAuthor(), 22 $this->renderOldValue(), 23 $this->renderNewValue()); 24 } 25 26 public function validateTransactions($object, array $xactions) { 27 $errors = array(); 28 29 if (!$this->isDuoProvider($object)) { 30 return $errors; 31 } 32 33 $old_value = $this->generateOldValue($object); 34 if ($this->isEmptyTextTransaction($old_value, $xactions)) { 35 $errors[] = $this->newRequiredError( 36 pht('Duo providers must have an API hostname.')); 37 } 38 39 foreach ($xactions as $xaction) { 40 $new_value = $xaction->getNewValue(); 41 42 if (!strlen($new_value)) { 43 continue; 44 } 45 46 if ($new_value === $old_value) { 47 continue; 48 } 49 50 try { 51 PhabricatorDuoAuthFactor::requireDuoAPIHostname($new_value); 52 } catch (Exception $ex) { 53 $errors[] = $this->newInvalidError( 54 $ex->getMessage(), 55 $xaction); 56 continue; 57 } 58 } 59 60 return $errors; 61 } 62 63}