Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/storage/PhabricatorExternalAccount.php
<?php | <?php | ||||
final class PhabricatorExternalAccount | final class PhabricatorExternalAccount | ||||
extends PhabricatorUserDAO | extends PhabricatorUserDAO | ||||
implements | implements | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorDestructibleInterface { | PhabricatorDestructibleInterface { | ||||
protected $userPHID; | protected $userPHID; | ||||
protected $accountType; | |||||
protected $accountDomain; | |||||
protected $accountSecret; | protected $accountSecret; | ||||
protected $accountID; | |||||
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; | protected $providerConfigPHID; | ||||
// TODO: Remove these (see T13493). These columns are obsolete and have | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
// no readers and only trivial writers. | |||||
protected $accountType; | |||||
protected $accountDomain; | |||||
protected $accountID; | |||||
private $profileImageFile = self::ATTACHABLE; | private $profileImageFile = self::ATTACHABLE; | ||||
private $providerConfig = self::ATTACHABLE; | private $providerConfig = self::ATTACHABLE; | ||||
private $accountIdentifiers = self::ATTACHABLE; | private $accountIdentifiers = self::ATTACHABLE; | ||||
public function getProfileImageFile() { | public function getProfileImageFile() { | ||||
return $this->assertAttached($this->profileImageFile); | return $this->assertAttached($this->profileImageFile); | ||||
} | } | ||||
Show All 23 Lines | return array( | ||||
'username' => 'text255?', | 'username' => 'text255?', | ||||
'realName' => 'text255?', | 'realName' => 'text255?', | ||||
'email' => 'text255?', | 'email' => 'text255?', | ||||
'emailVerified' => 'bool', | 'emailVerified' => 'bool', | ||||
'profileImagePHID' => 'phid?', | 'profileImagePHID' => 'phid?', | ||||
'accountURI' => 'text255?', | 'accountURI' => 'text255?', | ||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'account_details' => array( | |||||
'columns' => array('accountType', 'accountDomain', 'accountID'), | |||||
'unique' => true, | |||||
), | |||||
'key_user' => array( | 'key_user' => array( | ||||
'columns' => array('userPHID'), | 'columns' => array('userPHID'), | ||||
), | ), | ||||
'key_provider' => array( | |||||
'columns' => array('providerConfigPHID', 'userPHID'), | |||||
), | |||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function getProviderKey() { | |||||
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)); | ||||
} | } | ||||
$this->openTransaction(); | $this->openTransaction(); | ||||
$result = parent::save(); | $result = parent::save(); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | public function isUsableForLogin() { | ||||
$provider = $config->getProvider(); | $provider = $config->getProvider(); | ||||
if (!$provider->shouldAllowLogin()) { | if (!$provider->shouldAllowLogin()) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
public function getDisplayName() { | |||||
if (strlen($this->displayName)) { | |||||
return $this->displayName; | |||||
} | |||||
// TODO: Figure out how much identifying information we're going to show | |||||
// to users about external accounts. For now, just show a string which is | |||||
// clearly not an error, but don't disclose any identifying information. | |||||
$map = array( | |||||
'email' => pht('Email User'), | |||||
); | |||||
$type = $this->getAccountType(); | |||||
return idx($map, $type, pht('"%s" User', $type)); | |||||
} | |||||
public function attachProviderConfig(PhabricatorAuthProviderConfig $config) { | public function attachProviderConfig(PhabricatorAuthProviderConfig $config) { | ||||
$this->providerConfig = $config; | $this->providerConfig = $config; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getProviderConfig() { | public function getProviderConfig() { | ||||
return $this->assertAttached($this->providerConfig); | return $this->assertAttached($this->providerConfig); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |
This comment has a TODO.