Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/factor/PhabricatorSMSAuthFactor.php
<?php | <?php | ||||
final class PhabricatorSMSAuthFactor | final class PhabricatorSMSAuthFactor | ||||
extends PhabricatorAuthFactor { | extends PhabricatorAuthFactor { | ||||
public function getFactorKey() { | public function getFactorKey() { | ||||
return 'sms'; | return 'sms'; | ||||
} | } | ||||
public function getFactorName() { | public function getFactorName() { | ||||
return pht('Text Message (SMS)'); | |||||
} | |||||
public function getFactorShortName() { | |||||
return pht('SMS'); | return pht('SMS'); | ||||
} | } | ||||
public function getFactorCreateHelp() { | public function getFactorCreateHelp() { | ||||
return pht( | return pht( | ||||
'Allow users to receive a code via SMS.'); | 'Allow users to receive a code via SMS.'); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | final class PhabricatorSMSAuthFactor | ||||
public function canCreateNewConfiguration( | public function canCreateNewConfiguration( | ||||
PhabricatorAuthFactorProvider $provider, | PhabricatorAuthFactorProvider $provider, | ||||
PhabricatorUser $user) { | PhabricatorUser $user) { | ||||
if (!$this->loadUserContactNumber($user)) { | if (!$this->loadUserContactNumber($user)) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($this->loadConfigurationsForProvider($provider, $user)) { | |||||
return false; | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
public function getConfigurationCreateDescription( | public function getConfigurationCreateDescription( | ||||
PhabricatorAuthFactorProvider $provider, | PhabricatorAuthFactorProvider $provider, | ||||
PhabricatorUser $user) { | PhabricatorUser $user) { | ||||
$messages = array(); | $messages = array(); | ||||
if (!$this->loadUserContactNumber($user)) { | if (!$this->loadUserContactNumber($user)) { | ||||
$messages[] = id(new PHUIInfoView()) | $messages[] = id(new PHUIInfoView()) | ||||
->setSeverity(PHUIInfoView::SEVERITY_WARNING) | ->setSeverity(PHUIInfoView::SEVERITY_WARNING) | ||||
->setErrors( | ->setErrors( | ||||
array( | array( | ||||
pht( | pht( | ||||
'You have not configured a primary contact number. Configure '. | 'You have not configured a primary contact number. Configure '. | ||||
'a contact number before adding SMS as an authentication '. | 'a contact number before adding SMS as an authentication '. | ||||
'factor.'), | 'factor.'), | ||||
)); | )); | ||||
} | } | ||||
if ($this->loadConfigurationsForProvider($provider, $user)) { | |||||
$messages[] = id(new PHUIInfoView()) | |||||
->setSeverity(PHUIInfoView::SEVERITY_WARNING) | |||||
->setErrors( | |||||
array( | |||||
pht( | |||||
'You already have SMS authentication attached to your account.'), | |||||
)); | |||||
} | |||||
return $messages; | return $messages; | ||||
} | } | ||||
public function getEnrollDescription( | public function getEnrollDescription( | ||||
PhabricatorAuthFactorProvider $provider, | PhabricatorAuthFactorProvider $provider, | ||||
PhabricatorUser $user) { | PhabricatorUser $user) { | ||||
return pht( | return pht( | ||||
'To verify your phone as an authentication factor, a text message with '. | 'To verify your phone as an authentication factor, a text message with '. | ||||
▲ Show 20 Lines • Show All 280 Lines • Show Last 20 Lines |