Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/PhabricatorAuthStartController.php
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$providers = PhabricatorAuthProvider::getAllEnabledProviders(); | $providers = PhabricatorAuthProvider::getAllEnabledProviders(); | ||||
foreach ($providers as $key => $provider) { | foreach ($providers as $key => $provider) { | ||||
if (!$provider->shouldAllowLogin()) { | if (!$provider->shouldAllowLogin()) { | ||||
unset($providers[$key]); | unset($providers[$key]); | ||||
} | } | ||||
} | } | ||||
$configs = array(); | |||||
foreach ($providers as $provider) { | |||||
$configs[] = $provider->getProviderConfig(); | |||||
} | |||||
if (!$providers) { | if (!$providers) { | ||||
if ($this->isFirstTimeSetup()) { | if ($this->isFirstTimeSetup()) { | ||||
// If this is a fresh install, let the user register their admin | // If this is a fresh install, let the user register their admin | ||||
// account. | // account. | ||||
return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
->setURI($this->getApplicationURI('/register/')); | ->setURI($this->getApplicationURI('/register/')); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$invite_message = null; | $invite_message = null; | ||||
if ($invite) { | if ($invite) { | ||||
$invite_message = $this->renderInviteHeader($invite); | $invite_message = $this->renderInviteHeader($invite); | ||||
} | } | ||||
$custom_message = $this->newCustomStartMessage(); | $custom_message = $this->newCustomStartMessage(); | ||||
$email_login = $this->newEmailLoginView($configs); | |||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->addTextCrumb(pht('Login')); | $crumbs->addTextCrumb(pht('Login')); | ||||
$crumbs->setBorder(true); | $crumbs->setBorder(true); | ||||
$title = pht('Login'); | $title = pht('Login'); | ||||
$view = array( | $view = array( | ||||
$invite_message, | $invite_message, | ||||
$custom_message, | $custom_message, | ||||
$out, | $out, | ||||
$email_login, | |||||
); | ); | ||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->appendChild($view); | ->appendChild($view); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | private function newCustomStartMessage() { | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'auth-custom-message', | 'class' => 'auth-custom-message', | ||||
), | ), | ||||
$remarkup_view); | $remarkup_view); | ||||
} | } | ||||
private function newEmailLoginView(array $configs) { | |||||
assert_instances_of($configs, 'PhabricatorAuthProviderConfig'); | |||||
// Check if password auth is enabled. If it is, the password login form | |||||
// renders a "Forgot password?" link, so we don't need to provide a | |||||
// supplemental link. | |||||
$has_password = false; | |||||
foreach ($configs as $config) { | |||||
$provider = $config->getProvider(); | |||||
if ($provider instanceof PhabricatorPasswordAuthProvider) { | |||||
$has_password = true; | |||||
} | |||||
} | |||||
if ($has_password) { | |||||
return null; | |||||
} | |||||
$view = array( | |||||
pht('Trouble logging in?'), | |||||
' ', | |||||
phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => '/login/email/', | |||||
), | |||||
pht('Send a login link to your email address.')), | |||||
); | |||||
return phutil_tag( | |||||
'div', | |||||
array( | |||||
'class' => 'auth-custom-message', | |||||
), | |||||
$view); | |||||
} | |||||
} | } |