예제 #1
0
파일: Api.php 프로젝트: andrims21/eBri
 /**
  * Identify client identifed from current request.
  *
  * @return array
  */
 private function identifyClientFromRequest()
 {
     $clientId = $this->getRequest()->input('client_id', '');
     $clientSecret = $this->getRequest()->input('client_secret', null);
     $redirectUri = $this->getRequest()->input('redirect_uri', null);
     try {
         $this->accessToken = $this->getResource()->determineAccessToken();
         $sessionRepository = new FluentSession();
         $sesion = $sessionRepository->validateAccessToken($this->accessToken);
         if ($sesion !== false) {
             $clientId = $sesion['client_id'];
             $clientSecret = $sesion['client_secret'];
         }
         unset($sessionRepository);
         unset($sesion);
     } catch (InvalidAccessTokenException $e) {
     }
     if (!empty($clientId)) {
         $clientRepository = new FluentClient();
         $client = $clientRepository->getClient($clientId, $clientSecret, $redirectUri);
         if ($client !== false) {
             $client['id'] = $clientId;
             $client['secret'] = $client['client_secret'];
             unset($client['client_id']);
             unset($client['client_secret']);
             unset($client['redirect_uri']);
             unset($client['metadata']);
             $this->client = new OauthClient();
             $this->client->fill($client);
             $this->client->exists = true;
             $this->client->syncOriginal();
         }
         unset($client);
     }
     unset($clientId);
     unset($clientSecret);
     unset($redirectUri);
 }