From 809b347436ad9c7e9bac322ef497254723f8c26a Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 14 Nov 2016 10:47:39 +0100 Subject: [PATCH] apache gzip svg, _DEBUG_MODE, BadLoginException when bad JWT token --- app.js | 8 +++++++- conf/apache.conf | 2 +- debian/changelog | 2 +- env.js | 8 -------- env.php | 1 + pages/main/head.php | 4 ++-- web/json-service.php | 10 +++++----- web/rest-service.php | 2 +- web/service.php | 10 +++++++++- 9 files changed, 27 insertions(+), 20 deletions(-) delete mode 100644 env.js diff --git a/app.js b/app.js index 59f87a87..5407c0a9 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,11 @@ -require ('./env.js' ); +var host = window.location.host.split(':')[0]; + +if (_DEV_MODE) + host = host +':8080'; + +__webpack_public_path__ = '//'+ host +'/build/'; + require ('hedera/hedera'); window.onload = function () diff --git a/conf/apache.conf b/conf/apache.conf index cf8b07c4..e550f557 100644 --- a/conf/apache.conf +++ b/conf/apache.conf @@ -9,7 +9,7 @@ Order Allow,Deny Allow From All - + SetOutputFilter DEFLATE diff --git a/debian/changelog b/debian/changelog index b4b373d5..ce8d9119 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.387-deb8) stable; urgency=low +hedera-web (1.388-deb8) stable; urgency=low * Initial Release. diff --git a/env.js b/env.js deleted file mode 100644 index babad2f8..00000000 --- a/env.js +++ /dev/null @@ -1,8 +0,0 @@ - -var host = window.location.host.split(':')[0]; - -if (_DEV_MODE) - host = host +':8080'; - -__webpack_public_path__ = '//'+ host +'/build/'; - diff --git a/env.php b/env.php index df516f19..812cf90e 100644 --- a/env.php +++ b/env.php @@ -6,6 +6,7 @@ set_include_path (__DIR__.PATH_SEPARATOR.get_include_path ()); $vnAutoloadMap['vn/web'] = __DIR__.'/web'; +const _ENABLE_DEBUG = FALSE; const _DEV_MODE = TRUE; const _CONFIG_DIR = __DIR__.'/../../.config'; const _LOG_DIR = '/tmp'; diff --git a/pages/main/head.php b/pages/main/head.php index f04443c8..c25c13a1 100755 --- a/pages/main/head.php +++ b/pages/main/head.php @@ -12,6 +12,6 @@ if ($result = $db->query ('SELECT name, content FROM metatag')) $result->free (); } -$url = _DEV_MODE ? "http://{$_SERVER['SERVER_NAME']}:8080" : '.'; -$this->includeJs ("$url/build/hedera-web.js"); +$url = _DEV_MODE ? "http://{$_SERVER['SERVER_NAME']}:8080/" : ''; +$this->includeJs ("{$url}build/hedera-web.js"); diff --git a/web/json-service.php b/web/json-service.php index 846ee32b..be4cdf9e 100644 --- a/web/json-service.php +++ b/web/json-service.php @@ -58,12 +58,12 @@ class JsonService extends RestService $json = new JsonException (); - if (_DEV_MODE || $errno & $eUser) + if (_ENABLE_DEBUG || $errno & $eUser) $json->message = $message; else $json->message = s('Something went wrong'); - if (_DEV_MODE) + if (_ENABLE_DEBUG) { $json->code = $errno; $json->file = $file; @@ -91,7 +91,7 @@ class JsonService extends RestService { $json = new JsonException (); - if (_DEV_MODE || $e instanceof Lib\UserException) + if (_ENABLE_DEBUG || $e instanceof Lib\UserException) { $json->exception = get_class ($e); $json->message = $e->getMessage (); @@ -102,12 +102,12 @@ class JsonService extends RestService $json->message = s('Something went wrong'); } - if (_DEV_MODE) + if (_ENABLE_DEBUG) { $json->code = $e->getCode (); $json->file = $e->getFile (); $json->line = $e->getLine (); - $json->trace = $e->getTraceAsString (); + $json->trace = $e->getTrace (); } $this->statusFromException ($e); diff --git a/web/rest-service.php b/web/rest-service.php index b0624e33..d510dd43 100644 --- a/web/rest-service.php +++ b/web/rest-service.php @@ -11,7 +11,7 @@ class RestService extends Service { function run () { - ini_set ('display_errors', _DEV_MODE); + ini_set ('display_errors', _ENABLE_DEBUG); set_error_handler ([$this, 'errorHandler'], E_ALL); set_exception_handler ([$this, 'exceptionHandler']); diff --git a/web/service.php b/web/service.php index 00ba6c6d..cd3d92e1 100755 --- a/web/service.php +++ b/web/service.php @@ -162,7 +162,15 @@ abstract class Service $token = $_GET['token']; $key = $db->getValue ('SELECT jwtKey FROM config'); - $jwtPayload = Jwt::decode ($token, $key); + + try { + $jwtPayload = Jwt::decode ($token, $key); + } + catch (\Exception $e) + { + throw new BadLoginException ($e->getMessage ()); + } + $expiration = $jwtPayload['exp']; if (empty ($expiration) || $expiration <= time())