From 7f5bcd787b4fa9c609701ca8dae2f7ad96a48e11 Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Tue, 11 Aug 2020 12:26:38 +0200
Subject: [PATCH] FEAT #14455 TIME 2:00 Fix logo + application Name

---
 .../parameter/controllers/ParameterController.php    | 12 ++++++++++--
 src/app/user/controllers/UserController.php          |  2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/app/parameter/controllers/ParameterController.php b/src/app/parameter/controllers/ParameterController.php
index 139f458f578..02b90342e4a 100755
--- a/src/app/parameter/controllers/ParameterController.php
+++ b/src/app/parameter/controllers/ParameterController.php
@@ -104,7 +104,7 @@ class ParameterController
 
             $tmpPath = CoreConfigModel::getTmpPath();
             if ($args['id'] == 'logo') {
-                if (strpos($body['image'], 'data:image/jpeg;base64,') === false) {
+                if (strpos($body['image'], 'data:image/svg+xml;base64,') === false) {
                     return $response->withStatus(400)->withJson(['errors' => 'Body image is not a base64 image']);
                 }
                 $tmpFileName = $tmpPath . 'parameter_logo_' . rand() . '_file.svg';
@@ -134,8 +134,16 @@ class ParameterController
                     return $response->withStatus(400)->withJson(['errors' => 'Body size is not allowed']);
                 }
                 copy($tmpFileName, "custom/{$customId}/img/bodylogin.jpg");
+            } elseif ($args['id'] == 'applicationName') {
+                $config = CoreConfigModel::getJsonLoaded(['path' => 'apps/maarch_entreprise/xml/config.json']);
+                $config['config']['applicationName'] = $body['applicationName'];
+                $fp = fopen("custom/{$body['customId']}/apps/maarch_entreprise/xml/config.json", 'w');
+                fwrite($fp, json_encode($config, JSON_PRETTY_PRINT));
+                fclose($fp);
+            }
+            if (!empty($tmpFileName) && is_file($tmpFileName)) {
+                unset($tmpFileName);
             }
-            unset($tmpFileName);
             return $response->withStatus(204);
         }
 
diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php
index 071f4d7c15c..e8f013f79ef 100755
--- a/src/app/user/controllers/UserController.php
+++ b/src/app/user/controllers/UserController.php
@@ -288,7 +288,7 @@ class UserController
 
         if ($body['mode'] == 'rest' && isset($body['authorizedApi']) && is_array($body['authorizedApi'])) {
             foreach ($body['authorizedApi'] as $value) {
-                if (strpos($value, 'GET') !== 0 && strpos($value, 'POST') !== 0 && strpos($value, 'PUT') !== 0 && strpos($value, 'DELETE') !== 0) {
+                if (strpos($value, 'GET/') !== 0 && strpos($value, 'POST/') !== 0 && strpos($value, 'PUT/') !== 0 && strpos($value, 'DELETE/') !== 0) {
                     return $response->withStatus(400)->withJson(['errors' => 'Body authorizedApi is not well formatted']);
                 }
             }
-- 
GitLab