[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorOAuthServerTestController 4 extends PhabricatorOAuthServerController { 5 6 private $id; 7 8 public function shouldRequireLogin() { 9 return true; 10 } 11 12 public function willProcessRequest(array $data) { 13 $this->id = $data['id']; 14 } 15 16 public function processRequest() { 17 $request = $this->getRequest(); 18 $viewer = $request->getUser(); 19 20 $panels = array(); 21 $results = array(); 22 23 $client = id(new PhabricatorOAuthServerClientQuery()) 24 ->setViewer($viewer) 25 ->withIDs(array($this->id)) 26 ->executeOne(); 27 if (!$client) { 28 return new Aphront404Response(); 29 } 30 31 $view_uri = $client->getViewURI(); 32 33 // Look for an existing authorization. 34 $authorization = id(new PhabricatorOAuthClientAuthorizationQuery()) 35 ->setViewer($viewer) 36 ->withUserPHIDs(array($viewer->getPHID())) 37 ->withClientPHIDs(array($client->getPHID())) 38 ->executeOne(); 39 if ($authorization) { 40 $dialog = id(new AphrontDialogView()) 41 ->setUser($viewer) 42 ->setTitle(pht('Already Authorized')) 43 ->appendParagraph( 44 pht( 45 'You have already authorized this application to access your '. 46 'account.')) 47 ->addCancelButton($view_uri, pht('Close')); 48 49 return id(new AphrontDialogResponse())->setDialog($dialog); 50 } 51 52 if ($request->isFormPost()) { 53 $server = id(new PhabricatorOAuthServer()) 54 ->setUser($viewer) 55 ->setClient($client); 56 57 $scope = array(); 58 $authorization = $server->authorizeClient($scope); 59 60 $id = $authorization->getID(); 61 $panel_uri = '/settings/panel/oauthorizations/?id='.$id; 62 63 return id(new AphrontRedirectResponse())->setURI($panel_uri); 64 } 65 66 // TODO: It would be nice to put scope options in this dialog, maybe? 67 68 $dialog = id(new AphrontDialogView()) 69 ->setUser($viewer) 70 ->setTitle(pht('Authorize Application?')) 71 ->appendParagraph( 72 pht( 73 'This will create an authorization, permitting %s to access '. 74 'your account.', 75 phutil_tag('strong', array(), $client->getName()))) 76 ->addCancelButton($view_uri) 77 ->addSubmitButton(pht('Authorize Application')); 78 79 return id(new AphrontDialogResponse())->setDialog($dialog); 80 } 81 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |