@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 14 | 14 | use Symfony\Component\DependencyInjection\ContainerInterface; |
| 15 | 15 | |
| 16 | - abstract class AbstractController extends Controller |
|
| 16 | + abstract class AbstractController extends Controller |
|
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | $container->set('http', self::$http); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Creates and return a JSON Web Token through the OpenLRW API by using credentials filled in .env |
|
| 38 | - * |
|
| 39 | - * @return mixed|\Psr\Http\Message\ResponseInterface |
|
| 40 | - * @throws \GuzzleHttp\Exception\GuzzleException |
|
| 41 | - */ |
|
| 36 | + /** |
|
| 37 | + * Creates and return a JSON Web Token through the OpenLRW API by using credentials filled in .env |
|
| 38 | + * |
|
| 39 | + * @return mixed|\Psr\Http\Message\ResponseInterface |
|
| 40 | + * @throws \GuzzleHttp\Exception\GuzzleException |
|
| 41 | + */ |
|
| 42 | 42 | public static function generateJwt() |
| 43 | 43 | { |
| 44 | 44 | $_SESSION['JWT'] = json_decode( self::$http->request('POST', 'api/auth/login', [ |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | 'password' => env('API_PASSWORD') |
| 49 | 49 | ] |
| 50 | 50 | ])->getBody() |
| 51 | - ->getContents())->token; |
|
| 51 | + ->getContents())->token; |
|
| 52 | 52 | |
| 53 | 53 | return $_SESSION['JWT']; |
| 54 | 54 | |
@@ -124,26 +124,26 @@ discard block |
||
| 124 | 124 | return ldap_get_entries($this->__get('ldap'), $this->searchLDAP($filter, $arg))[0]; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Function to check if OpenLRW is up |
|
| 129 | - * |
|
| 130 | - * @return boolean |
|
| 131 | - * @throws \GuzzleHttp\Exception\GuzzleException |
|
| 132 | - */ |
|
| 133 | - public static function isUp() |
|
| 134 | - { |
|
| 135 | - return self::$http->request('GET', '/info.json')->getStatusCode() == 200; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Get the logged username |
|
| 140 | - * |
|
| 141 | - * @return mixed |
|
| 142 | - */ |
|
| 143 | - public static function loggedUser() |
|
| 144 | - { |
|
| 145 | - return $_SESSION['phpCAS']['user']; |
|
| 146 | - } |
|
| 127 | + /** |
|
| 128 | + * Function to check if OpenLRW is up |
|
| 129 | + * |
|
| 130 | + * @return boolean |
|
| 131 | + * @throws \GuzzleHttp\Exception\GuzzleException |
|
| 132 | + */ |
|
| 133 | + public static function isUp() |
|
| 134 | + { |
|
| 135 | + return self::$http->request('GET', '/info.json')->getStatusCode() == 200; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Get the logged username |
|
| 140 | + * |
|
| 141 | + * @return mixed |
|
| 142 | + */ |
|
| 143 | + public static function loggedUser() |
|
| 144 | + { |
|
| 145 | + return $_SESSION['phpCAS']['user']; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | \ No newline at end of file |
@@ -68,10 +68,10 @@ |
||
| 68 | 68 | */ |
| 69 | 69 | public function post(String $route, array $args) // ToDo : add JWT |
| 70 | 70 | { |
| 71 | - return json_decode( self::$http->request('POST', $route, [ |
|
| 72 | - 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' ], |
|
| 73 | - 'json' => $args |
|
| 74 | - ])->getBody()->getContents()); |
|
| 71 | + return json_decode( self::$http->request('POST', $route, [ |
|
| 72 | + 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' ], |
|
| 73 | + 'json' => $args |
|
| 74 | + ])->getBody()->getContents()); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |