Differential D20645 Diff 49252 src/applications/auth/controller/config/PhabricatorAuthEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/config/PhabricatorAuthEditController.php
| <?php | <?php | ||||
| final class PhabricatorAuthEditController | final class PhabricatorAuthEditController | ||||
| extends PhabricatorAuthProviderConfigController { | extends PhabricatorAuthProviderConfigController { | ||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $this->requireApplicationCapability( | $this->requireApplicationCapability( | ||||
| AuthManageProvidersCapability::CAPABILITY); | AuthManageProvidersCapability::CAPABILITY); | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $provider_class = $request->getStr('provider'); | $provider_class = $request->getStr('provider'); | ||||
| $config_id = $request->getURIData('id'); | $config_id = $request->getURIData('id'); | ||||
| $locked_config_key = 'auth.lock-config'; | |||||
| $is_locked = PhabricatorEnv::getEnvConfig($locked_config_key); | |||||
| if ($is_locked) { | |||||
| $message = pht( | |||||
| 'Authentication provider configuration is locked, and can not be '. | |||||
| 'changed without being unlocked. See the configuration setting %s '. | |||||
| 'for details.', | |||||
| phutil_tag( | |||||
| 'a', | |||||
| array( | |||||
| 'href' => '/config/edit/'.$locked_config_key, | |||||
| ), | |||||
| $locked_config_key)); | |||||
| $dialog = id(new AphrontDialogView()) | |||||
| ->setUser($viewer) | |||||
| ->setMethod('GET') | |||||
epriestley: You can reduce boilerplate with `return $this->newDialog()->...` in a `Controller`, and… | |||||
| ->setTitle(pht('Authentication Config Locked')) | |||||
| ->appendChild($message) | |||||
| ->addCancelButton($this->getApplicationURI()); | |||||
| return id(new AphrontDialogResponse())->setDialog($dialog); | |||||
| } | |||||
| if ($config_id) { | if ($config_id) { | ||||
| $config = id(new PhabricatorAuthProviderConfigQuery()) | $config = id(new PhabricatorAuthProviderConfigQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->requireCapabilities( | ->requireCapabilities( | ||||
| array( | array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| )) | )) | ||||
| ▲ Show 20 Lines • Show All 345 Lines • Show Last 20 Lines | |||||
You can reduce boilerplate with return $this->newDialog()->... in a Controller, and setMethod() shouldn't be necessary (cancel buttons are just links that look like buttons visually, only "submit" is ever actually a button).