Skip to content
Snippets Groups Projects
Commit c55a6340 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #8925 TIME 0:40 get user picture in MP

parent 7a0446e8
No related branches found
No related tags found
No related merge requests found
......@@ -382,6 +382,8 @@ $app->post('/saveNumericPackage', \Sendmail\Controllers\ReceiveMessageExchangeCo
$app->post('/saveMessageExchangeReturn', \Sendmail\Controllers\ReceiveMessageExchangeController::class . ':saveMessageExchangeReturn');
$app->post('/saveMessageExchangeReview', \Sendmail\Controllers\MessageExchangeReviewController::class . ':saveMessageExchangeReview');
$app->get('/maarchParapheur/user/{id}/picture', \ExternalSignatoryBook\controllers\MaarchParapheurController::class . ':getUserPicture');
$app->get('/xParaphWorkflow', \ExternalSignatoryBook\controllers\XParaphController::class . ':getWorkflow');
$app->post('/xParaphAccount', \ExternalSignatoryBook\controllers\XParaphController::class . ':createXparaphAccount');
$app->delete('/xParaphAccount', \ExternalSignatoryBook\controllers\XParaphController::class . ':deleteXparaphAccount');
......
......@@ -23,7 +23,10 @@ use Note\models\NoteModel;
use Priority\models\PriorityModel;
use Resource\controllers\SummarySheetController;
use Resource\models\ResModel;
use Respect\Validation\Validator;
use setasign\Fpdi\Tcpdf\Fpdi;
use Slim\Http\Request;
use Slim\Http\Response;
use SrcCore\models\CoreConfigModel;
use SrcCore\models\CurlModel;
use User\models\UserModel;
......@@ -420,4 +423,49 @@ class MaarchParapheurController
$state['mode'] = $step['mode'];
return $state;
}
public static function getUserPicture(Request $request, Response $response, array $aArgs)
{
$check = Validator::intVal()->validate($aArgs['id']);
if (!$check) {
return $response->withStatus(400)->withJson(['errors' => 'id should be an integer']);
}
$loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/visa/xml/remoteSignatoryBooks.xml']);
if ($loadedXml->signatoryBookEnabled == 'maarchParapheur') {
foreach ($loadedXml->signatoryBook as $value) {
if ($value->id == "maarchParapheur") {
$url = $value->url;
$userId = $value->userId;
$password = $value->password;
break;
}
}
$curlResponse = CurlModel::execSimple([
'url' => rtrim($url, '/') . '/rest/users/'.$aArgs['id'].'/picture',
'basicAuth' => ['user' => $userId, 'password' => $password],
'headers' => ['content-type:application/json'],
'method' => 'GET'
]);
if ($curlResponse['code'] != '200') {
if (!empty($curlResponse['response']['errors'])) {
$errors = $curlResponse['response']['errors'];
} else {
$errors = $curlResponse['errors'];
}
if (empty($errors)) {
$errors = 'An error occured. Please check your configuration file.';
}
return $response->withStatus(400)->withJson(['errors' => $errors]);
}
} else {
return $response->withStatus(403)->withJson(['errors' => 'maarchParapheur is not enabled']);
}
return $response->withJson(['picture' => $curlResponse['response']['picture']]);
}
}
......@@ -121,7 +121,7 @@ class AutoCompleteController
$data = $request->getQueryParams();
$check = Validator::stringType()->notEmpty()->validate($data['search']);
if (!$check) {
return $response->withStatus(400)->withJson(['errors' => 'Bad Request']);
return $response->withStatus(400)->withJson(['errors' => 'search is empty']);
}
$loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/visa/xml/remoteSignatoryBooks.xml']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment