Пример #1
0
 /**
  * Overrule this method when you want to display a nice page when
  * the authorization is finished.  This function does not know if the authorization was
  * succesfull, you need to check the token in the database.
  *
  * @param boolean authorized	if the current token (oauth_token param) is authorized or not
  * @param int user_id			user for which the token was authorized (or denied)
  * @return string verifier  For 1.0a Compatibility
  */
 public function authorizeFinish($authorized, IIdentity $account, $token, $callback)
 {
     //$token = $this->request->getParam('oauth_token', true);
     $verifier = null;
     if ($this->session->get('verify_oauth_token') == $token) {
         // Flag the token as authorized, or remove the token when not authorized
         $store = $this->store;
         // Fetch the referrer host from the oauth callback parameter
         $referrer_host = '';
         $oauth_callback = false;
         $verify_oauth_callback = $callback;
         if (!empty($verify_oauth_callback) && $verify_oauth_callback != 'oob') {
             $oauth_callback = $callback;
             $ps = parse_url($oauth_callback);
             if (isset($ps['host'])) {
                 $referrer_host = $ps['host'];
             }
         }
         if ($authorized) {
             //$this->logger->addNote('Authorized token "'.$token.'" for user '.$account->email.' with referrer "'.$referrer_host.'"');
             // 1.0a Compatibility : create a verifier code
             $verifier = $store->authorizeConsumerRequestToken($token, $account, $referrer_host);
         } else {
             //$this->logger->addNote('Authorization rejected for token "'.$token.'" for user '.$account->email."\nToken has been deleted");
             $store->deleteConsumerRequestToken($token);
         }
         //$logger->alert("service: callback ze sešny: ".$oauth_callback);
         if (!empty($oauth_callback)) {
             //$params = array('oauth_token' => rawurlencode($token));
             // 1.0a Compatibility : if verifier code has been generated, add it to the URL
             //if ($verifier) {
             //    $params['oauth_verifier'] = $verifier;
             //}
             $uri = preg_replace('/\\s/', '%20', $oauth_callback);
             if (!empty($this->allowed_uri_schemes)) {
                 if (!in_array(substr($uri, 0, strpos($uri, '://')), $this->allowed_uri_schemes)) {
                     throw new OauthException('Illegal protocol in redirect uri ' . $uri);
                 }
             } else {
                 if (!empty($this->disallowed_uri_schemes)) {
                     if (in_array(substr($uri, 0, strpos($uri, '://')), $this->disallowed_uri_schemes)) {
                         throw new OauthException('Illegal protocol in redirect uri ' . $uri);
                     }
                 }
             }
             $oauth_callback = $oauth_callback . "?oauth_token=" . rawurlencode($token);
             return $this->response->redirect($oauth_callback, true);
         }
     }
 }
 /**
  * @return mixed
  */
 public function getUser()
 {
     $userId = (int) $this->_session->get($this->_config['session_key'], false);
     return $userId ? AdminUsers::findFirstById($userId) : false;
 }
Пример #3
0
 /**
  * @return \Phalcon\Config
  */
 public function getData()
 {
     return $this->session->get(self::KEY, new Config());
 }
Пример #4
0
 /**
  * @param string $key
  * @param null $defaultValue
  * @return mixed
  */
 public function get($key, $defaultValue = null)
 {
     //p('get key:' . $this->getId() . '_' . $key);
     return $this->storage->get($this->getId() . '_' . $key);
 }