Explorar el Código

FD3-317 Fix chequeo de token

Guillermo Espinoza hace 7 años
padre
commit
b8c87a6793
Se han modificado 1 ficheros con 5 adiciones y 7 borrados
  1. 5 7
      Services/Webservice.php

+ 5 - 7
Services/Webservice.php

@@ -125,15 +125,13 @@ class Webservice
     {
         try {
             $headers = array();
-            if ($token = $this->securityTokenStorage->getToken()) {
-                if (method_exists($token, 'getAccessToken')) {
-                    $headers[] = 'Authorization: Bearer ' . $token->getAccessToken();
-                }
+            $token = $this->securityTokenStorage->getToken();
+            if ($token && method_exists($token, 'getAccessToken')) {
+                $headers[] = 'Authorization: Bearer ' . $token->getAccessToken();
             } elseif (!empty($credentials) && isset($credentials['username']) && isset($credentials['password'])) {
                 $headers[] = 'Authorization: Basic ' . base64_encode($credentials['username'] . ":" . $credentials['password']);
-            } else {
-                return '';
             }
+
             $request = new HttpRequest($method, $url);
             if (!empty($data)) {
                 $headers[] = 'Content-Type: application/x-www-form-urlencoded';
@@ -144,7 +142,7 @@ class Webservice
             $this->httpClient->send($request, $response);
             $response = $response->getContent();
         } catch (RequestException $ex) {
-            $response = '';
+            throw $ex;
         }
 
         return $response;