public function getRefreshToken($clientConfigId, Context $context)
 {
     if (!isset($_SESSION['php-oauth-client']['refresh_token'])) {
         return false;
     }
     foreach ($_SESSION['php-oauth-client']['refresh_token'] as $t) {
         $token = unserialize($t);
         if ($clientConfigId !== $token->getClientConfigId()) {
             continue;
         }
         if ($context->getUserId() !== $token->getUserId()) {
             continue;
         }
         if (!$token->getScope()->hasScope($context->getScope())) {
             continue;
         }
         return $token;
     }
     return false;
 }
Example #2
0
 protected function getScopedKeyIfAppliccable($key, $prepend_scope)
 {
     $scope_id = Context::getScope() instanceof \thebuggenie\core\entities\Scope ? Context::getScope()->getID() : '';
     $key = $this->_prefix . $key;
     return $prepend_scope ? "{$key}.{$scope_id}" : $key;
 }
Example #3
0
 /**
  * Sets a cookie on the client, default expiration is one day
  *
  * @param $key string the cookie key
  * @param $value string the cookie value
  * @param $expiration integer when the cookie expires (seconds from now)
  *
  * @return bool
  */
 public function setCookie($key, $value, $expiration = 864000)
 {
     $expiration = $expiration !== null ? NOW + $expiration : null;
     $secure = Context::getScope()->isSecure();
     setcookie($key, $value, $expiration, Context::getWebroot(), null, $secure);
     return true;
 }