Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/storage/PhabricatorExternalAccount.php
Show All 10 Lines | final class PhabricatorExternalAccount extends PhabricatorUserDAO | ||||
protected $displayName; | protected $displayName; | ||||
protected $username; | protected $username; | ||||
protected $realName; | protected $realName; | ||||
protected $email; | protected $email; | ||||
protected $emailVerified = 0; | protected $emailVerified = 0; | ||||
protected $accountURI; | protected $accountURI; | ||||
protected $profileImagePHID; | protected $profileImagePHID; | ||||
protected $properties = array(); | protected $properties = array(); | ||||
protected $providerConfigPHID; | |||||
private $profileImageFile = self::ATTACHABLE; | private $profileImageFile = self::ATTACHABLE; | ||||
private $providerConfig = self::ATTACHABLE; | |||||
public function getProfileImageFile() { | public function getProfileImageFile() { | ||||
return $this->assertAttached($this->profileImageFile); | return $this->assertAttached($this->profileImageFile); | ||||
} | } | ||||
public function attachProfileImageFile(PhabricatorFile $file) { | public function attachProfileImageFile(PhabricatorFile $file) { | ||||
$this->profileImageFile = $file; | $this->profileImageFile = $file; | ||||
return $this; | return $this; | ||||
Show All 31 Lines | return array( | ||||
), | ), | ||||
'key_user' => array( | 'key_user' => array( | ||||
'columns' => array('userPHID'), | 'columns' => array('userPHID'), | ||||
), | ), | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function getPhabricatorUser() { | |||||
$tmp_usr = id(new PhabricatorUser()) | |||||
->makeEphemeral() | |||||
->setPHID($this->getPHID()); | |||||
return $tmp_usr; | |||||
} | |||||
public function getProviderKey() { | public function getProviderKey() { | ||||
return $this->getAccountType().':'.$this->getAccountDomain(); | return $this->getAccountType().':'.$this->getAccountDomain(); | ||||
} | } | ||||
public function save() { | public function save() { | ||||
if (!$this->getAccountSecret()) { | if (!$this->getAccountSecret()) { | ||||
$this->setAccountSecret(Filesystem::readRandomCharacters(32)); | $this->setAccountSecret(Filesystem::readRandomCharacters(32)); | ||||
} | } | ||||
return parent::save(); | return parent::save(); | ||||
} | } | ||||
public function setProperty($key, $value) { | public function setProperty($key, $value) { | ||||
$this->properties[$key] = $value; | $this->properties[$key] = $value; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getProperty($key, $default = null) { | public function getProperty($key, $default = null) { | ||||
return idx($this->properties, $key, $default); | return idx($this->properties, $key, $default); | ||||
} | } | ||||
public function isUsableForLogin() { | public function isUsableForLogin() { | ||||
$key = $this->getProviderKey(); | $config = $this->getProviderConfig(); | ||||
$provider = PhabricatorAuthProvider::getEnabledProviderByKey($key); | if (!$config->getIsEnabled()) { | ||||
if (!$provider) { | |||||
return false; | return false; | ||||
} | } | ||||
$provider = $config->getProvider(); | |||||
if (!$provider->shouldAllowLogin()) { | if (!$provider->shouldAllowLogin()) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
public function getDisplayName() { | public function getDisplayName() { | ||||
Show All 9 Lines | $map = array( | ||||
'email' => pht('Email User'), | 'email' => pht('Email User'), | ||||
); | ); | ||||
$type = $this->getAccountType(); | $type = $this->getAccountType(); | ||||
return idx($map, $type, pht('"%s" User', $type)); | return idx($map, $type, pht('"%s" User', $type)); | ||||
} | } | ||||
public function attachProviderConfig(PhabricatorAuthProviderConfig $config) { | |||||
$this->providerConfig = $config; | |||||
return $this; | |||||
} | |||||
public function getProviderConfig() { | |||||
return $this->assertAttached($this->providerConfig); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
Show All 28 Lines |