Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/storage/PhabricatorAuthInvite.php
Show All 32 Lines | protected function getConfiguration() { | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function generatePHID() { | public function generatePHID() { | ||||
return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
PhabricatorAuthInvitePHIDType::TYPECONST); | PhabricatorAuthInvitePHIDType::TYPECONST); | ||||
} | } | ||||
public function regenerateVerificationCode() { | |||||
$this->verificationCode = Filesystem::readRandomCharacters(16); | |||||
$this->verificationHash = null; | |||||
return $this; | |||||
} | |||||
public function getVerificationCode() { | public function getVerificationCode() { | ||||
if (!$this->getVerificationHash()) { | if (!$this->verificationCode) { | ||||
if ($this->verificationHash) { | if ($this->verificationHash) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Verification code can not be regenerated after an invite is '. | 'Verification code can not be regenerated after an invite is '. | ||||
'created.')); | 'created.')); | ||||
} | } | ||||
$this->verificationCode = Filesystem::readRandomCharacters(16); | $this->regenerateVerificationCode(); | ||||
} | } | ||||
return $this->verificationCode; | return $this->verificationCode; | ||||
} | } | ||||
public function save() { | public function save() { | ||||
if (!$this->getVerificationHash()) { | if (!$this->getVerificationHash()) { | ||||
$hash = PhabricatorHash::digestForIndex($this->getVerificationCode()); | $hash = PhabricatorHash::digestForIndex($this->getVerificationCode()); | ||||
$this->setVerificationHash($hash); | $this->setVerificationHash($hash); | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |