From a86d96ffd9dc9a2e24bf010cf1feb6f43b59309f Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Wed, 20 May 2020 14:30:23 +0200 Subject: [PATCH] FEAT #13339 TIME 0:25 Control email when webservice user --- src/app/contact/controllers/ContactController.php | 10 +++++++++- .../controllers/IndexingModelController.php | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/contact/controllers/ContactController.php b/src/app/contact/controllers/ContactController.php index ce7248672ae..15bb093bd4c 100755 --- a/src/app/contact/controllers/ContactController.php +++ b/src/app/contact/controllers/ContactController.php @@ -139,7 +139,15 @@ class ContactController if (!empty($control['errors'])) { return $response->withStatus(400)->withJson(['errors' => $control['errors']]); } - + + $currentUser = UserModel::getById(['id' => $GLOBALS['id'], 'select' => ['loginmode']]); + if (!empty($body['email']) && $currentUser['loginmode'] == 'restMode') { + $contact = ContactModel::get(['select' => ['id'], 'where' => ['email = ?'], 'data' => [$body['email']]]); + if (!empty($contact[0]['id'])) { + return $response->withJson(['id' => $contact[0]['id']]); + } + } + if (!empty($body['communicationMeans'])) { if (filter_var($body['communicationMeans'], FILTER_VALIDATE_EMAIL)) { $body['communicationMeans'] = ['email' => $body['communicationMeans']]; diff --git a/src/app/indexingModel/controllers/IndexingModelController.php b/src/app/indexingModel/controllers/IndexingModelController.php index 7ea73aedbc6..4c414a7a61c 100755 --- a/src/app/indexingModel/controllers/IndexingModelController.php +++ b/src/app/indexingModel/controllers/IndexingModelController.php @@ -421,7 +421,6 @@ class IndexingModelController 'where' => ['model_id = ?'], 'data' => [$args['id']] ]); - if (!empty($resources)) { return $response->withStatus(400)->withJson(['errors' => 'Model is used by at least one resource', 'lang' => 'modelUsedByResources']); } -- GitLab