From a4bab60ad0aeb002277b52dcd5b67c286819e3e1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 6 Feb 2019 18:11:36 -0800 Subject: [PATCH] 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 --- ...orAuthProvidersGuidanceEngineExtension.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/applications/auth/guidance/PhabricatorAuthProvidersGuidanceEngineExtension.php b/src/applications/auth/guidance/PhabricatorAuthProvidersGuidanceEngineExtension.php index ac3fe4d309..d1f67393ca 100644 --- a/src/applications/auth/guidance/PhabricatorAuthProvidersGuidanceEngineExtension.php +++ b/src/applications/auth/guidance/PhabricatorAuthProvidersGuidanceEngineExtension.php @@ -10,6 +10,26 @@ final class PhabricatorAuthProvidersGuidanceEngineExtension } 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_link = $this->renderConfigLink($domains_key); $domains_value = PhabricatorEnv::getEnvConfig($domains_key);