Commit b6aa7119 authored by poslovitch's avatar poslovitch
Browse files

Application des correctifs de M. Micard

parent 06249eca
...@@ -10,7 +10,7 @@ function get_product_short_data_array($product_full_data){ ...@@ -10,7 +10,7 @@ function get_product_short_data_array($product_full_data){
$shortproduct = null; $shortproduct = null;
//check if product description contains mandatory fields //check if product description contains mandatory fields
if (array_key_exists("product_name_fr", $product_full_data) && if (array_key_exists("id", $product_full_data) && array_key_exists("product_name_fr", $product_full_data) &&
!empty($product_full_data["product_name_fr"]) && array_key_exists("image_url", $product_full_data) && !empty($product_full_data["product_name_fr"]) && array_key_exists("image_url", $product_full_data) &&
!empty($product_full_data["image_url"]) && array_key_exists("nutriscore_grade", $product_full_data) && !empty($product_full_data["image_url"]) && array_key_exists("nutriscore_grade", $product_full_data) &&
!empty($product_full_data["nutriscore_grade"])) !empty($product_full_data["nutriscore_grade"]))
......
...@@ -420,21 +420,26 @@ $app->delete('/api/users/{username}', function( Request $request, Response $resp ...@@ -420,21 +420,26 @@ $app->delete('/api/users/{username}', function( Request $request, Response $resp
}); });
/** /**
* Function which parse token, decode user infos from this token and Throws * Function which parse token, decode user infos from this token and Throws UnauthenticatedException
* UnauthenticatedException if Authentication Issue. * if Authentication Issue.
* *
* The UnauthenticatedException must be catched in the caller and should result * The UnauthenticatedException must be catched in the caller and should result to a 401 Http Error
* to a 401 Http Error
*/ */
function get_token_infos(Request $request){ function get_token_infos(Request $request){
if ($request->hasHeader('Authorization')) { if ($request->hasHeader('Authorization')) {
list($token) = sscanf($request->getHeaderLine('Authorization'), 'Bearer %s'); list($token) = sscanf($request->getHeaderLine('Authorization'), 'Bearer %s');
$jwt = new Auth\JwtHandler(); $jwt = new Auth\JwtHandler();
try
$data = $jwt->_jwt_decode_data($token); {
$data = $jwt->_jwt_decode_data($token);
return $data; return $data;
}
catch (Exception $e)
{
throw new Auth\UnauthenticatedException("Invalid token : ". $e->getMessage());
}
} }
else{ else{
throw new Auth\UnauthenticatedException("Unable to find Authorization Header"); throw new Auth\UnauthenticatedException("Unable to find Authorization Header");
......
...@@ -7,6 +7,9 @@ use Psr\Http\Message\ResponseInterface as Response; ...@@ -7,6 +7,9 @@ use Psr\Http\Message\ResponseInterface as Response;
// # include the Slim framework // # include the Slim framework
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
// Report simple running errors
error_reporting(E_ERROR | E_PARSE);
$config['displayErrorDetails'] = true; $config['displayErrorDetails'] = true;
$config['addContentLengthHeader'] = false; $config['addContentLengthHeader'] = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment