2014-06-04 01:50:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorAuthNeedsMultiFactorController
|
|
|
|
extends PhabricatorAuthController {
|
|
|
|
|
|
|
|
public function shouldRequireMultiFactorEnrollment() {
|
|
|
|
// Users need access to this controller in order to enroll in multi-factor
|
|
|
|
// auth.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-02 01:49:27 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
2014-06-04 01:50:27 +02:00
|
|
|
|
2015-01-02 05:20:08 +01:00
|
|
|
$panel = id(new PhabricatorMultiFactorSettingsPanel())
|
2014-06-04 01:50:27 +02:00
|
|
|
->setUser($viewer)
|
|
|
|
->setViewer($viewer)
|
|
|
|
->setOverrideURI($this->getApplicationURI('/multifactor/'))
|
|
|
|
->processRequest($request);
|
|
|
|
|
|
|
|
if ($panel instanceof AphrontResponse) {
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addTextCrumb(pht('Add Multi-Factor Auth'));
|
|
|
|
|
|
|
|
$viewer->updateMultiFactorEnrollment();
|
|
|
|
|
|
|
|
if (!$viewer->getIsEnrolledInMultiFactor()) {
|
2015-03-01 23:45:56 +01:00
|
|
|
$help = id(new PHUIInfoView())
|
2014-06-04 01:50:27 +02:00
|
|
|
->setTitle(pht('Add Multi-Factor Authentication To Your Account'))
|
2015-03-01 23:45:56 +01:00
|
|
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
2014-06-04 01:50:27 +02:00
|
|
|
->setErrors(
|
|
|
|
array(
|
|
|
|
pht(
|
|
|
|
'Before you can use Phabricator, you need to add multi-factor '.
|
|
|
|
'authentication to your account.'),
|
|
|
|
pht(
|
|
|
|
'Multi-factor authentication helps secure your account by '.
|
|
|
|
'making it more difficult for attackers to gain access or '.
|
2015-05-22 09:27:56 +02:00
|
|
|
'take sensitive actions.'),
|
2014-06-04 01:50:27 +02:00
|
|
|
pht(
|
|
|
|
'To learn more about multi-factor authentication, click the '.
|
|
|
|
'%s button below.',
|
|
|
|
phutil_tag('strong', array(), pht('Help'))),
|
|
|
|
pht(
|
|
|
|
'To add an authentication factor, click the %s button below.',
|
|
|
|
phutil_tag('strong', array(), pht('Add Authentication Factor'))),
|
|
|
|
pht(
|
|
|
|
'To continue, add at least one authentication factor to your '.
|
|
|
|
'account.'),
|
|
|
|
));
|
|
|
|
} else {
|
2015-03-01 23:45:56 +01:00
|
|
|
$help = id(new PHUIInfoView())
|
2014-06-04 01:50:27 +02:00
|
|
|
->setTitle(pht('Multi-Factor Authentication Configured'))
|
2015-03-01 23:45:56 +01:00
|
|
|
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
|
2014-06-04 01:50:27 +02:00
|
|
|
->setErrors(
|
|
|
|
array(
|
|
|
|
pht(
|
|
|
|
'You have successfully configured multi-factor authentication '.
|
|
|
|
'for your account.'),
|
|
|
|
pht(
|
|
|
|
'You can make adjustments from the Settings panel later.'),
|
|
|
|
pht(
|
|
|
|
'When you are ready, %s.',
|
|
|
|
phutil_tag(
|
|
|
|
'strong',
|
|
|
|
array(),
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/',
|
|
|
|
),
|
|
|
|
pht('continue to Phabricator')))),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2016-03-31 22:45:02 +02:00
|
|
|
$view = array(
|
|
|
|
$help,
|
|
|
|
$panel,
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle(pht('Add Multi-Factor Authentication'))
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild($view);
|
|
|
|
|
2014-06-04 01:50:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|