apache gzip svg, _DEBUG_MODE, BadLoginException when bad JWT token

This commit is contained in:
Juan Ferrer Toribio 2016-11-14 10:47:39 +01:00
parent 058493124b
commit 809b347436
9 changed files with 27 additions and 20 deletions

8
app.js
View File

@ -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'); require ('hedera/hedera');
window.onload = function () window.onload = function ()

View File

@ -9,7 +9,7 @@
Order Allow,Deny Order Allow,Deny
Allow From All Allow From All
<FilesMatch "\.(css|js|json|php|xml|html)$"> <FilesMatch "\.(css|js|json|php|xml|html|svg)$">
SetOutputFilter DEFLATE SetOutputFilter DEFLATE
</FilesMatch> </FilesMatch>

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.387-deb8) stable; urgency=low hedera-web (1.388-deb8) stable; urgency=low
* Initial Release. * Initial Release.

8
env.js
View File

@ -1,8 +0,0 @@
var host = window.location.host.split(':')[0];
if (_DEV_MODE)
host = host +':8080';
__webpack_public_path__ = '//'+ host +'/build/';

View File

@ -6,6 +6,7 @@ set_include_path (__DIR__.PATH_SEPARATOR.get_include_path ());
$vnAutoloadMap['vn/web'] = __DIR__.'/web'; $vnAutoloadMap['vn/web'] = __DIR__.'/web';
const _ENABLE_DEBUG = FALSE;
const _DEV_MODE = TRUE; const _DEV_MODE = TRUE;
const _CONFIG_DIR = __DIR__.'/../../.config'; const _CONFIG_DIR = __DIR__.'/../../.config';
const _LOG_DIR = '/tmp'; const _LOG_DIR = '/tmp';

View File

@ -12,6 +12,6 @@ if ($result = $db->query ('SELECT name, content FROM metatag'))
$result->free (); $result->free ();
} }
$url = _DEV_MODE ? "http://{$_SERVER['SERVER_NAME']}:8080" : '.'; $url = _DEV_MODE ? "http://{$_SERVER['SERVER_NAME']}:8080/" : '';
$this->includeJs ("$url/build/hedera-web.js"); $this->includeJs ("{$url}build/hedera-web.js");

View File

@ -58,12 +58,12 @@ class JsonService extends RestService
$json = new JsonException (); $json = new JsonException ();
if (_DEV_MODE || $errno & $eUser) if (_ENABLE_DEBUG || $errno & $eUser)
$json->message = $message; $json->message = $message;
else else
$json->message = s('Something went wrong'); $json->message = s('Something went wrong');
if (_DEV_MODE) if (_ENABLE_DEBUG)
{ {
$json->code = $errno; $json->code = $errno;
$json->file = $file; $json->file = $file;
@ -91,7 +91,7 @@ class JsonService extends RestService
{ {
$json = new JsonException (); $json = new JsonException ();
if (_DEV_MODE || $e instanceof Lib\UserException) if (_ENABLE_DEBUG || $e instanceof Lib\UserException)
{ {
$json->exception = get_class ($e); $json->exception = get_class ($e);
$json->message = $e->getMessage (); $json->message = $e->getMessage ();
@ -102,12 +102,12 @@ class JsonService extends RestService
$json->message = s('Something went wrong'); $json->message = s('Something went wrong');
} }
if (_DEV_MODE) if (_ENABLE_DEBUG)
{ {
$json->code = $e->getCode (); $json->code = $e->getCode ();
$json->file = $e->getFile (); $json->file = $e->getFile ();
$json->line = $e->getLine (); $json->line = $e->getLine ();
$json->trace = $e->getTraceAsString (); $json->trace = $e->getTrace ();
} }
$this->statusFromException ($e); $this->statusFromException ($e);

View File

@ -11,7 +11,7 @@ class RestService extends Service
{ {
function run () function run ()
{ {
ini_set ('display_errors', _DEV_MODE); ini_set ('display_errors', _ENABLE_DEBUG);
set_error_handler ([$this, 'errorHandler'], E_ALL); set_error_handler ([$this, 'errorHandler'], E_ALL);
set_exception_handler ([$this, 'exceptionHandler']); set_exception_handler ([$this, 'exceptionHandler']);

View File

@ -162,7 +162,15 @@ abstract class Service
$token = $_GET['token']; $token = $_GET['token'];
$key = $db->getValue ('SELECT jwtKey FROM config'); $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']; $expiration = $jwtPayload['exp'];
if (empty ($expiration) || $expiration <= time()) if (empty ($expiration) || $expiration <= time())