コード例 #1
0
ファイル: ApiController.php プロジェクト: henvic/MediaLab
 public function authorizeAction()
 {
     $auth = Zend_Auth::getInstance();
     $store = OAuthStore::instance();
     $registry = Zend_Registry::getInstance();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $request = $this->getRequest();
     if (!$auth->hasIdentity()) {
         Zend_Controller_Front::getInstance()->registerPlugin(new Ml_Plugins_LoginRedirect());
     }
     $this->_helper->loadOauthstore->preloadServer();
     $server = new OAuthServer();
     $form = Ml_Model_Api::authorizeForm();
     // Check if there is a valid request token in the current request
     // Returns an array with the
     //consumer key, consumer secret, token, token secret and token type.
     $rs = $server->authorizeVerify();
     $consumer = $store->getConsumer($rs['consumer_key'], $auth->getIdentity());
     $this->view->consumerInfo = $consumer;
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $values = $form->getValues();
         if (isset($values['allow'])) {
             $authorized = true;
         } else {
             if (isset($values['deny'])) {
                 $authorized = false;
             }
         }
         if (isset($authorized)) {
             $server->authorizeFinish($authorized, $auth->getIdentity());
             //If no oauth_callback, the user is redirected to
             $this->_redirect($router->assemble(array(), "accountapps") . "?new_addition", array("exit"));
         }
     }
     $this->view->authorizeForm = $form;
 }