Commit 42827796 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #17005 TIME 2:10 save loginMessage

parent cc4c0ec7
......@@ -84,6 +84,9 @@ $app->delete('/connectors/{id}', \ExternalSignatoryBook\controllers\ExternalSign
$app->put('/connectors/{id}', \ExternalSignatoryBook\controllers\ExternalSignatoryBookController::class . ':update');
$app->get('/connectors/{id}/currentVisa', \ExternalSignatoryBook\controllers\ExternalSignatoryBookController::class . ':getCurrentVisa');
//Customization
$app->put('/customization', \Configuration\controllers\ConfigurationController::class . ':updateCustomization');
//Documents
$app->post('/documents', \Document\controllers\DocumentController::class . ':create');
$app->get('/documents', \Document\controllers\DocumentController::class . ':get');
......
......@@ -359,6 +359,42 @@ class ConfigurationController
return $response->withJson(['connection' => true, 'informations' => 'success']);
}
public function updateCustomization(Request $request, Response $response, array $args)
{
if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_customization'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
}
$body = $request->getParsedBody();
if (empty($body)) {
return $response->withStatus(400)->withJson(['errors' => 'Body is not set or empty']);
} elseif (!Validator::stringType()->notEmpty()->validate($body['loginMessage'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body loginMessage is empty or not a string']);
}
$configuration = ConfigurationModel::getByIdentifier(['identifier' => 'customization']);
if (empty($configuration[0])) {
return $response->withStatus(400)->withJson(['errors' => 'Configuration does not exist']);
}
$configuration = $configuration[0];
$data = json_encode(['loginMessage' => $body['loginMessage']]);
ConfigurationModel::update(['set' => ['value' => $data], 'where' => ['id = ?'], 'data' => [$configuration['id']]]);
HistoryController::add([
'code' => 'OK',
'objectType' => 'configurations',
'objectId' => $configuration['id'],
'type' => 'MODIFICATION',
'message' => "{configurationUpdated} : {$configuration['label']}",
'data' => ['identifier' => $configuration['identifier']]
]);
return $response->withStatus(204);
}
private static function checkMailer(array $args)
{
if (!Validator::stringType()->notEmpty()->validate($args['type'])) {
......
......@@ -28,7 +28,7 @@ class PrivilegeController
['id' => 'manage_password_rules', 'type' => 'admin', 'icon' => 'lock-closed', 'route' => '/administration/passwordRules'],
['id' => 'manage_history', 'type' => 'admin', 'icon' => 'timer-outline', 'route' => '/administration/history'],
['id' => 'manage_otp_connectors', 'type' => 'admin', 'icon' => 'people-circle-outline', 'route' => '/administration/otps'],
['id' => 'manage_customization', 'type' => 'admin', 'icon' => 'color-wand-outline', 'route' => '/administration/customization'],
['id' => 'manage_customization', 'type' => 'admin', 'icon' => 'color-wand-outline', 'route' => '/administration/customization'],
['id' => 'manage_documents', 'type' => 'simple'],
['id' => 'indexation', 'type' => 'simple']
];
......
......@@ -51,12 +51,16 @@ class AuthenticationController
$mailServerOnline = !empty($emailConfiguration['online']);
$customization = ConfigurationModel::getByIdentifier(['identifier' => 'customization', 'select' => ['value']]);
$customization = !empty($customization[0]['value']) ? json_decode($customization[0]['value'], true) : null;
return $response->withJson([
'connection' => $connection,
'changeKey' => $encryptKey == 'Security Key Maarch Parapheur #2008',
'instanceId' => $hashedPath,
'coreUrl' => $coreUrl,
'mailServerOnline' => $mailServerOnline,
'loginMessage' => $customization['loginMessage']
]);
}
......
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