Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / auth / xaction / PhabricatorAuthFactorProviderDuoHostnameTransaction.php
blob27ae2711377bfe60b774f17d14f07d2891b61060
1 <?php
3 final class PhabricatorAuthFactorProviderDuoHostnameTransaction
4 extends PhabricatorAuthFactorProviderTransactionType {
6 const TRANSACTIONTYPE = 'duo.hostname';
8 public function generateOldValue($object) {
9 $key = PhabricatorDuoAuthFactor::PROP_HOSTNAME;
10 return $object->getAuthFactorProviderProperty($key);
13 public function applyInternalEffects($object, $value) {
14 $key = PhabricatorDuoAuthFactor::PROP_HOSTNAME;
15 $object->setAuthFactorProviderProperty($key, $value);
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());
26 public function validateTransactions($object, array $xactions) {
27 $errors = array();
29 if (!$this->isDuoProvider($object)) {
30 return $errors;
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.'));
39 foreach ($xactions as $xaction) {
40 $new_value = $xaction->getNewValue();
42 if (!strlen($new_value)) {
43 continue;
46 if ($new_value === $old_value) {
47 continue;
50 try {
51 PhabricatorDuoAuthFactor::requireDuoAPIHostname($new_value);
52 } catch (Exception $ex) {
53 $errors[] = $this->newInvalidError(
54 $ex->getMessage(),
55 $xaction);
56 continue;
60 return $errors;