Differential D11356 Diff 27285 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 { | ||||
private $providerClass; | public function handleRequest(AphrontRequest $request) { | ||||
private $configID; | $this->requireApplicationCapability( | ||||
AuthManageProvidersCapability::CAPABILITY); | |||||
public function willProcessRequest(array $data) { | |||||
$this->providerClass = idx($data, 'className'); | |||||
$this->configID = idx($data, 'id'); | |||||
} | |||||
public function processRequest() { | |||||
$request = $this->getRequest(); | |||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$provider_class = $request->getURIData('className'); | |||||
$config_id = $request->getURIData('configID'); | |||||
if ($this->configID) { | 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, | ||||
)) | )) | ||||
->withIDs(array($this->configID)) | ->withIDs(array($config_id)) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$config) { | if (!$config) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$provider = $config->getProvider(); | $provider = $config->getProvider(); | ||||
if (!$provider) { | if (!$provider) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$is_new = false; | $is_new = false; | ||||
} else { | } else { | ||||
$providers = PhabricatorAuthProvider::getAllBaseProviders(); | $providers = PhabricatorAuthProvider::getAllBaseProviders(); | ||||
foreach ($providers as $candidate_provider) { | foreach ($providers as $candidate_provider) { | ||||
if (get_class($candidate_provider) === $this->providerClass) { | if (get_class($candidate_provider) === $provider_class) { | ||||
$provider = $candidate_provider; | $provider = $candidate_provider; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (!$provider) { | if (!$provider) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |