diff --git a/api/index.php b/api/index.php index 7c266a1..0b32953 100644 --- a/api/index.php +++ b/api/index.php @@ -14,6 +14,10 @@ if (PHP_SAPI == 'cli-server') { require __DIR__ . '/../vendor/autoload.php'; +if (!defined('FRONTEND')) { + define('FRONTEND', false); +} + // Instantiate the app $settings = require __DIR__ . '/../src/settings.php'; $local_settings = require __DIR__ . '/../src/settings-local.php'; diff --git a/index.php b/index.php index 7db27ee..cc44863 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ getContainer(); $app->get('/', function ($request, $response) { diff --git a/src/routes/asset.php b/src/routes/asset.php index 936b79a..8ce9470 100644 --- a/src/routes/asset.php +++ b/src/routes/asset.php @@ -2,11 +2,11 @@ // Asset routes // Searches through the list of assets -$app->get('/asset', function ($request, $response, $args) { global $frontend; +$app->get('/asset', function ($request, $response, $args) { $params = $request->getQueryParams(); $category = '%'; - if(isset($frontend) && $frontend) { + if(FRONTEND) { $category_type = $this->constants['category_type']['any']; } else { $category_type = $this->constants['category_type']['addon']; @@ -186,7 +186,7 @@ $get_asset = function ($request, $response, $args) { }; // Binding to multiple routes $app->get('/asset/{id:[0-9]+}', $get_asset); -if(isset($frontend) && $frontend) { +if(FRONTEND) { $app->get('/asset/{id:[0-9]+}/edit', $get_asset); } diff --git a/src/routes/asset_edit.php b/src/routes/asset_edit.php index 5c92f7f..30bbf9e 100644 --- a/src/routes/asset_edit.php +++ b/src/routes/asset_edit.php @@ -405,7 +405,7 @@ $get_edit = function ($request, $response, $args) { // Binding to multiple routes $app->get('/asset/edit/{id:[0-9]+}', $get_edit); -if(isset($frontend) && $frontend) { +if(FRONTEND) { $app->get('/asset/edit/{id:[0-9]+}/edit', $get_edit); } diff --git a/src/routes/auth.php b/src/routes/auth.php index cdd5ecc..2c17c9a 100644 --- a/src/routes/auth.php +++ b/src/routes/auth.php @@ -3,7 +3,7 @@ // Initializes the connection by sending all categories available -$app->get('/configure', function ($request, $response, $args) { global $frontend; +$app->get('/configure', function ($request, $response, $args) { $params = $request->getQueryParams(); $category_type = $this->constants['category_type']['addon']; @@ -29,7 +29,7 @@ $app->get('/configure', function ($request, $response, $args) { global $frontend 'categories' => $query->fetchAll(), 'token' => $token, 'login_url' => $_SERVER['HTTP_HOST'] . - (isset($frontend) && $frontend ? dirname($request->getUri()->getBasePath()) : $request->getUri()->getBasePath()) . + (FRONTEND ? dirname($request->getUri()->getBasePath()) : $request->getUri()->getBasePath()) . '/login#' . urlencode($token), // ^ TODO: Make those routes actually work ], 200); @@ -138,7 +138,7 @@ $app->post('/login', function ($request, $response, $args) { } }); -if(isset($frontend) && $frontend) { // Doesn't work for non-frontend, since we can't unissue tokens -- to logout from api/ just drop the token. +if(FRONTEND) { // Doesn't work for non-frontend, since we can't unissue tokens -- to logout from api/ just drop the token. $app->get('/logout', function ($request, $response, $args) { return $response->withJson([ 'authenticated' => false, diff --git a/src/routes/user.php b/src/routes/user.php index 7befbd4..383b186 100644 --- a/src/routes/user.php +++ b/src/routes/user.php @@ -43,6 +43,6 @@ $get_feed = function ($request, $response, $args) { // Binding to multiple routes $app->post('/user/feed', $get_feed); -if(isset($frontend) && $frontend) { - $app->get('/user/feed', $get_feed); +if(FRONTEND) { + $app->get('/user/feed', $get_feed); }