1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Don't show "registration might be too open" warnings unless an auth provider actually allows registration

Summary:
Depends on D20118. Fixes T5351. We possibly raise some warnings about registration (approval queue, email domains), but they aren't relevant if no one can register.

Hide these warnings if no providers actually support registration.

Test Plan: Viewed the Auth provider list with registration providers and with no registration providers, saw more tailored guidance.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T5351

Differential Revision: https://secure.phabricator.com/D20119
This commit is contained in:
epriestley 2019-02-06 18:11:36 -08:00
parent 7469075a83
commit a4bab60ad0

View file

@ -10,6 +10,26 @@ final class PhabricatorAuthProvidersGuidanceEngineExtension
} }
public function generateGuidance(PhabricatorGuidanceContext $context) { public function generateGuidance(PhabricatorGuidanceContext $context) {
$configs = id(new PhabricatorAuthProviderConfigQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withIsEnabled(true)
->execute();
$allows_registration = false;
foreach ($configs as $config) {
$provider = $config->getProvider();
if ($provider->shouldAllowRegistration()) {
$allows_registration = true;
break;
}
}
// If no provider allows registration, we don't need provide any warnings
// about registration being too open.
if (!$allows_registration) {
return array();
}
$domains_key = 'auth.email-domains'; $domains_key = 'auth.email-domains';
$domains_link = $this->renderConfigLink($domains_key); $domains_link = $this->renderConfigLink($domains_key);
$domains_value = PhabricatorEnv::getEnvConfig($domains_key); $domains_value = PhabricatorEnv::getEnvConfig($domains_key);