@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 127 lines 3.0 kB view raw
1<?php 2 3 4final class PhabricatorAuthFactorConfig 5 extends PhabricatorAuthDAO 6 implements 7 PhabricatorPolicyInterface, 8 PhabricatorDestructibleInterface { 9 10 protected $userPHID; 11 protected $factorProviderPHID; 12 protected $factorName; 13 protected $factorSecret; 14 protected $properties = array(); 15 16 private $sessionEngine; 17 private $factorProvider = self::ATTACHABLE; 18 private $mfaSyncToken; 19 20 protected function getConfiguration() { 21 return array( 22 self::CONFIG_SERIALIZATION => array( 23 'properties' => self::SERIALIZATION_JSON, 24 ), 25 self::CONFIG_AUX_PHID => true, 26 self::CONFIG_COLUMN_SCHEMA => array( 27 'factorName' => 'text', 28 'factorSecret' => 'text', 29 ), 30 self::CONFIG_KEY_SCHEMA => array( 31 'key_user' => array( 32 'columns' => array('userPHID'), 33 ), 34 ), 35 ) + parent::getConfiguration(); 36 } 37 38 public function getPHIDType() { 39 return PhabricatorAuthAuthFactorPHIDType::TYPECONST; 40 } 41 42 public function attachFactorProvider( 43 PhabricatorAuthFactorProvider $provider) { 44 $this->factorProvider = $provider; 45 return $this; 46 } 47 48 public function getFactorProvider() { 49 return $this->assertAttached($this->factorProvider); 50 } 51 52 public function setSessionEngine(PhabricatorAuthSessionEngine $engine) { 53 $this->sessionEngine = $engine; 54 return $this; 55 } 56 57 public function getSessionEngine() { 58 if (!$this->sessionEngine) { 59 throw new PhutilInvalidStateException('setSessionEngine'); 60 } 61 62 return $this->sessionEngine; 63 } 64 65 public function setMFASyncToken(PhabricatorAuthTemporaryToken $token) { 66 $this->mfaSyncToken = $token; 67 return $this; 68 } 69 70 public function getMFASyncToken() { 71 return $this->mfaSyncToken; 72 } 73 74 public function getAuthFactorConfigProperty($key, $default = null) { 75 return idx($this->properties, $key, $default); 76 } 77 78 public function setAuthFactorConfigProperty($key, $value) { 79 $this->properties[$key] = $value; 80 return $this; 81 } 82 83 public function newSortVector() { 84 return id(new PhutilSortVector()) 85 ->addInt($this->getFactorProvider()->newStatus()->getOrder()) 86 ->addInt($this->getID()); 87 } 88 89 90/* -( PhabricatorPolicyInterface )----------------------------------------- */ 91 92 93 public function getCapabilities() { 94 return array( 95 PhabricatorPolicyCapability::CAN_VIEW, 96 PhabricatorPolicyCapability::CAN_EDIT, 97 ); 98 } 99 100 public function getPolicy($capability) { 101 return $this->getUserPHID(); 102 } 103 104 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 105 return false; 106 } 107 108 109/* -( PhabricatorDestructibleInterface )----------------------------------- */ 110 111 112 public function destroyObjectPermanently( 113 PhabricatorDestructionEngine $engine) { 114 115 $user = id(new PhabricatorPeopleQuery()) 116 ->setViewer($engine->getViewer()) 117 ->withPHIDs(array($this->getUserPHID())) 118 ->executeOne(); 119 120 $this->delete(); 121 122 if ($user) { 123 $user->updateMultiFactorEnrollment(); 124 } 125 } 126 127}