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){
$shortproduct = null;
//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["image_url"]) && array_key_exists("nutriscore_grade", $product_full_data) &&
!empty($product_full_data["nutriscore_grade"]))
......
......@@ -420,22 +420,27 @@ $app->delete('/api/users/{username}', function( Request $request, Response $resp
});
/**
* Function which parse token, decode user infos from this token and Throws
* UnauthenticatedException if Authentication Issue.
* Function which parse token, decode user infos from this token and Throws UnauthenticatedException
* if Authentication Issue.
*
* The UnauthenticatedException must be catched in the caller and should result
* to a 401 Http Error
* The UnauthenticatedException must be catched in the caller and should result to a 401 Http Error
*/
function get_token_infos(Request $request){
if ($request->hasHeader('Authorization')) {
list($token) = sscanf($request->getHeaderLine('Authorization'), 'Bearer %s');
$jwt = new Auth\JwtHandler();
try
{
$data = $jwt->_jwt_decode_data($token);
return $data;
}
catch (Exception $e)
{
throw new Auth\UnauthenticatedException("Invalid token : ". $e->getMessage());
}
}
else{
throw new Auth\UnauthenticatedException("Unable to find Authorization Header");
}
......
......@@ -7,6 +7,9 @@ use Psr\Http\Message\ResponseInterface as Response;
// # include the Slim framework
require __DIR__ . '/../vendor/autoload.php';
// Report simple running errors
error_reporting(E_ERROR | E_PARSE);
$config['displayErrorDetails'] = true;
$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