Path: blob/master/src/applications/oauthserver/controller/client/PhabricatorOAuthClientDisableController.php
12242 views
<?php12final class PhabricatorOAuthClientDisableController3extends PhabricatorOAuthClientController {45public function handleRequest(AphrontRequest $request) {6$viewer = $this->getViewer();78$client = id(new PhabricatorOAuthServerClientQuery())9->setViewer($viewer)10->withIDs(array($request->getURIData('id')))11->requireCapabilities(12array(13PhabricatorPolicyCapability::CAN_VIEW,14PhabricatorPolicyCapability::CAN_EDIT,15))16->executeOne();17if (!$client) {18return new Aphront404Response();19}2021$done_uri = $client->getViewURI();22$is_disable = !$client->getIsDisabled();2324if ($request->isFormPost()) {25$xactions = array();2627$xactions[] = id(new PhabricatorOAuthServerTransaction())28->setTransactionType(PhabricatorOAuthServerTransaction::TYPE_DISABLED)29->setNewValue((int)$is_disable);3031$editor = id(new PhabricatorOAuthServerEditor())32->setActor($viewer)33->setContentSourceFromRequest($request)34->setContinueOnNoEffect(true)35->setContinueOnMissingFields(true)36->applyTransactions($client, $xactions);3738return id(new AphrontRedirectResponse())->setURI($done_uri);39}4041if ($is_disable) {42$title = pht('Disable OAuth Application');43$body = pht(44'Really disable the %s OAuth application? Users will no longer be '.45'able to authenticate against it, nor access this server using '.46'tokens generated by this application.',47phutil_tag('strong', array(), $client->getName()));48$button = pht('Disable Application');49} else {50$title = pht('Enable OAuth Application');51$body = pht(52'Really enable the %s OAuth application? Users will be able to '.53'authenticate against it, and existing tokens will become usable '.54'again.',55phutil_tag('strong', array(), $client->getName()));56$button = pht('Enable Application');57}5859return $this->newDialog()60->setTitle($title)61->appendParagraph($body)62->addCancelButton($done_uri)63->addSubmitButton($button);64}6566}676869