Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/storage/PhabricatorUser.php
| Show All 32 Lines | final class PhabricatorUser | ||||
| protected $consoleEnabled = 0; | protected $consoleEnabled = 0; | ||||
| protected $consoleVisible = 0; | protected $consoleVisible = 0; | ||||
| protected $consoleTab = ''; | protected $consoleTab = ''; | ||||
| protected $conduitCertificate; | protected $conduitCertificate; | ||||
| protected $isSystemAgent = 0; | protected $isSystemAgent = 0; | ||||
| protected $isMailingList = 0; | |||||
| protected $isAdmin = 0; | protected $isAdmin = 0; | ||||
| protected $isDisabled = 0; | protected $isDisabled = 0; | ||||
| protected $isEmailVerified = 0; | protected $isEmailVerified = 0; | ||||
| protected $isApproved = 0; | protected $isApproved = 0; | ||||
| protected $isEnrolledInMultiFactor = 0; | protected $isEnrolledInMultiFactor = 0; | ||||
| protected $accountSecret; | protected $accountSecret; | ||||
| Show All 19 Lines | switch ($field) { | ||||
| date_default_timezone_get()); | date_default_timezone_get()); | ||||
| // Make sure these return booleans. | // Make sure these return booleans. | ||||
| case 'isAdmin': | case 'isAdmin': | ||||
| return (bool)$this->isAdmin; | return (bool)$this->isAdmin; | ||||
| case 'isDisabled': | case 'isDisabled': | ||||
| return (bool)$this->isDisabled; | return (bool)$this->isDisabled; | ||||
| case 'isSystemAgent': | case 'isSystemAgent': | ||||
| return (bool)$this->isSystemAgent; | return (bool)$this->isSystemAgent; | ||||
| case 'isMailingList': | |||||
| return (bool)$this->isMailingList; | |||||
| case 'isEmailVerified': | case 'isEmailVerified': | ||||
| return (bool)$this->isEmailVerified; | return (bool)$this->isEmailVerified; | ||||
| case 'isApproved': | case 'isApproved': | ||||
| return (bool)$this->isApproved; | return (bool)$this->isApproved; | ||||
| default: | default: | ||||
| return parent::readField($field); | return parent::readField($field); | ||||
| } | } | ||||
| } | } | ||||
| Show All 23 Lines | if (PhabricatorUserEmail::isEmailVerificationRequired()) { | ||||
| if (!$this->getIsEmailVerified()) { | if (!$this->getIsEmailVerified()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function canEstablishWebSessions() { | |||||
| if (!$this->isUserActivated()) { | |||||
| return false; | |||||
| } | |||||
| if ($this->getIsMailingList()) { | |||||
| return false; | |||||
| } | |||||
| if ($this->getIsSystemAgent()) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| public function canEstablishAPISessions() { | |||||
| if (!$this->isUserActivated()) { | |||||
| return false; | |||||
| } | |||||
| if ($this->getIsMailingList()) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| public function canEstablishSSHSessions() { | |||||
| if (!$this->isUserActivated()) { | |||||
| return false; | |||||
| } | |||||
| if ($this->getIsMailingList()) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
btrahan: these are nice | |||||
| /** | /** | ||||
| * Returns `true` if this is a standard user who is logged in. Returns `false` | * Returns `true` if this is a standard user who is logged in. Returns `false` | ||||
| * for logged out, anonymous, or external users. | * for logged out, anonymous, or external users. | ||||
| * | * | ||||
| * @return bool `true` if the user is a standard user who is logged in with | * @return bool `true` if the user is a standard user who is logged in with | ||||
| * a normal session. | * a normal session. | ||||
| */ | */ | ||||
| public function getIsStandardUser() { | public function getIsStandardUser() { | ||||
| Show All 12 Lines | return array( | ||||
| 'passwordSalt' => 'text32?', | 'passwordSalt' => 'text32?', | ||||
| 'passwordHash' => 'text128?', | 'passwordHash' => 'text128?', | ||||
| 'profileImagePHID' => 'phid?', | 'profileImagePHID' => 'phid?', | ||||
| 'consoleEnabled' => 'bool', | 'consoleEnabled' => 'bool', | ||||
| 'consoleVisible' => 'bool', | 'consoleVisible' => 'bool', | ||||
| 'consoleTab' => 'text64', | 'consoleTab' => 'text64', | ||||
| 'conduitCertificate' => 'text255', | 'conduitCertificate' => 'text255', | ||||
| 'isSystemAgent' => 'bool', | 'isSystemAgent' => 'bool', | ||||
| 'isMailingList' => 'bool', | |||||
| 'isDisabled' => 'bool', | 'isDisabled' => 'bool', | ||||
| 'isAdmin' => 'bool', | 'isAdmin' => 'bool', | ||||
| 'timezoneIdentifier' => 'text255', | 'timezoneIdentifier' => 'text255', | ||||
| 'isEmailVerified' => 'uint32', | 'isEmailVerified' => 'uint32', | ||||
| 'isApproved' => 'uint32', | 'isApproved' => 'uint32', | ||||
| 'accountSecret' => 'bytes64', | 'accountSecret' => 'bytes64', | ||||
| 'isEnrolledInMultiFactor' => 'bool', | 'isEnrolledInMultiFactor' => 'bool', | ||||
| 'profileImageCache' => 'text255?', | 'profileImageCache' => 'text255?', | ||||
| ▲ Show 20 Lines • Show All 876 Lines • ▼ Show 20 Lines | public function getCapabilities() { | ||||
| ); | ); | ||||
| } | } | ||||
| public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
| switch ($capability) { | switch ($capability) { | ||||
| case PhabricatorPolicyCapability::CAN_VIEW: | case PhabricatorPolicyCapability::CAN_VIEW: | ||||
| return PhabricatorPolicies::POLICY_PUBLIC; | return PhabricatorPolicies::POLICY_PUBLIC; | ||||
| case PhabricatorPolicyCapability::CAN_EDIT: | case PhabricatorPolicyCapability::CAN_EDIT: | ||||
| if ($this->getIsSystemAgent()) { | if ($this->getIsSystemAgent() || $this->getIsMailingList()) { | ||||
| return PhabricatorPolicies::POLICY_ADMIN; | return PhabricatorPolicies::POLICY_ADMIN; | ||||
| } else { | } else { | ||||
| return PhabricatorPolicies::POLICY_NOONE; | return PhabricatorPolicies::POLICY_NOONE; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | ||||
| ▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines | |||||
these are nice