[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 abstract class PhabricatorAuthFactor extends Phobject { 4 5 abstract public function getFactorName(); 6 abstract public function getFactorKey(); 7 abstract public function getFactorDescription(); 8 abstract public function processAddFactorForm( 9 AphrontFormView $form, 10 AphrontRequest $request, 11 PhabricatorUser $user); 12 13 abstract public function renderValidateFactorForm( 14 PhabricatorAuthFactorConfig $config, 15 AphrontFormView $form, 16 PhabricatorUser $viewer, 17 $validation_result); 18 19 abstract public function processValidateFactorForm( 20 PhabricatorAuthFactorConfig $config, 21 PhabricatorUser $viewer, 22 AphrontRequest $request); 23 24 public function isFactorValid( 25 PhabricatorAuthFactorConfig $config, 26 $validation_result) { 27 return (idx($validation_result, 'valid') === true); 28 } 29 30 public function getParameterName( 31 PhabricatorAuthFactorConfig $config, 32 $name) { 33 return 'authfactor.'.$config->getID().'.'.$name; 34 } 35 36 public static function getAllFactors() { 37 static $factors; 38 39 if ($factors === null) { 40 $map = id(new PhutilSymbolLoader()) 41 ->setAncestorClass(__CLASS__) 42 ->loadObjects(); 43 44 $factors = array(); 45 foreach ($map as $factor) { 46 $key = $factor->getFactorKey(); 47 if (empty($factors[$key])) { 48 $factors[$key] = $factor; 49 } else { 50 $this_class = get_class($factor); 51 $that_class = get_class($factors[$key]); 52 53 throw new Exception( 54 pht( 55 'Two auth factors (with classes "%s" and "%s") both provide '. 56 'implementations with the same key ("%s"). Each factor must '. 57 'have a unique key.', 58 $this_class, 59 $that_class, 60 $key)); 61 } 62 } 63 } 64 65 return $factors; 66 } 67 68 protected function newConfigForUser(PhabricatorUser $user) { 69 return id(new PhabricatorAuthFactorConfig()) 70 ->setUserPHID($user->getPHID()) 71 ->setFactorKey($this->getFactorKey()); 72 } 73 74 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |