Commit 97f4c26f authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX #16982 TIME 0:30 Improve controle for mandatory signature position +...

FIX #16982 TIME 0:30 Improve controle for mandatory signature position + improve controle on connectors route
parent 1f9cbf11
......@@ -365,7 +365,7 @@ class DocumentController
if ($hasElectronicSignature && $workflow['signatureMode'] == 'stamp' && $workflow['mode'] == 'sign') {
return $response->withStatus(400)->withJson(['errors' => "Body workflow[{$key}] signatureMode cannot be stamp after an electronic signature", 'lang' => 'stampInTheMiddleImpossible']);
}
if ($workflow['externalInformations']['role'] == 'sign_yousign' && empty($workflow['signaturePositions'])) {
if ($workflow['externalInformations']['role'] == 'otp_sign_yousign' && empty($workflow['signaturePositions'])) {
return $response->withStatus(400)->withJson(['errors' => "Body workflow[{$key}] signaturePositions must be set for sign_yousign role"]);
}
if (!empty($workflow['signaturePositions'])) {
......
......@@ -39,15 +39,16 @@ class ExternalSignatoryBookController
public function getById(Request $request, Response $response, array $args)
{
if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_otp_connectors'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
}
if (!Validator::intVal()->notEmpty()->validate($args['id'])) {
return $response->withStatus(400)->withJson(['errors' => 'Route id must be an integer']);
}
$connector = ExternalSignatoryBookModel::getById(['id' => $args['id']]);
$select = [];
if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_otp_connectors'])) {
$select = ['otp_code'];
}
$connector = ExternalSignatoryBookModel::getById(['select' => $select, 'id' => $args['id']]);
if (empty($connector)) {
return $response->withStatus(400)->withJson(['errors' => 'Connector not found']);
}
......@@ -55,13 +56,15 @@ class ExternalSignatoryBookController
$connector['securityModes'] = json_decode($connector['otp_code'], true);
unset($connector['otp_code']);
$connector['message'] = json_decode($connector['message_content'], true);
unset($connector['message_content']);
$connectionData = json_decode($connector['connection_data'], true);
$connector['apiUri'] = $connectionData['apiUri'];
$connector['apiKey'] = $connectionData['apiKey'];
unset($connector['connection_data']);
if (PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_otp_connectors'])) {
$connector['message'] = json_decode($connector['message_content'], true);
unset($connector['message_content']);
$connectionData = json_decode($connector['connection_data'], true);
$connector['apiUri'] = $connectionData['apiUri'];
$connector['apiKey'] = $connectionData['apiKey'];
unset($connector['connection_data']);
}
return $response->withJson(['otp' => $connector]);
}
......
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