getScope() public method

public getScope ( )
示例#1
0
 public function getRefreshToken($clientConfigId, Context $context)
 {
     $stmt = $this->db->prepare("SELECT * FROM refresh_tokens WHERE client_config_id = :client_config_id AND user_id = :user_id AND scope = :scope");
     $stmt->bindValue(":client_config_id", $clientConfigId, PDO::PARAM_STR);
     $stmt->bindValue(":user_id", $context->getUserId(), PDO::PARAM_STR);
     $stmt->bindValue(":scope", $context->getScope()->isEmptyScope() ? null : $context->getScope()->getScopeAsString(), PDO::PARAM_STR);
     $stmt->execute();
     $result = $stmt->fetch(PDO::FETCH_ASSOC);
     if (false !== $result) {
         $result['scope'] = new Scope($result['scope']);
         return new RefreshToken($result);
     }
     return false;
 }
示例#2
0
 public function getRefreshToken($clientConfigId, Context $context)
 {
     $stmt = $this->db->prepare(sprintf('SELECT * FROM %s WHERE client_config_id = :client_config_id AND user_id = :user_id AND scope = :scope', $this->prefix . 'refresh_tokens'));
     $stmt->bindValue(':client_config_id', $clientConfigId, PDO::PARAM_STR);
     $stmt->bindValue(':user_id', $context->getUserId(), PDO::PARAM_STR);
     $stmt->bindValue(':scope', $context->getScope()->toString(), PDO::PARAM_STR);
     $stmt->execute();
     $result = $stmt->fetch(PDO::FETCH_ASSOC);
     if (false !== $result) {
         $result['scope'] = Scope::fromString($result['scope']);
         return new RefreshToken($result);
     }
     return false;
 }
 public function getRefreshToken($clientConfigId, Context $context)
 {
     try {
         $refresh_token_cache = \Cache::get('php-oauth-client.refresh_token.' . $this->cacheId);
     } catch (\CacheNotFoundException $e) {
         return false;
     }
     foreach ($refresh_token_cache 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;
 }