EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
ref
Yuri Kuznetsov0f501420738b
diff --git a/application/Espo/Classes/Record/User/InputFilter.php b/application/Espo/Classes/Record/User/InputFilter.phpnew file mode 100644index 0000000000..cd3c0094b5--- /dev/null+++ b/application/Espo/Classes/Record/User/InputFilter.php@@ -0,0 +1,58 @@+<?php+/************************************************************************+ * This file is part of EspoCRM.+ *+ * EspoCRM – Open Source CRM application.+ * Copyright (C) 2014-2025 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko+ * Website: https://www.espocrm.com+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ * The interactive user interfaces in modified source and object code versions+ * of this program must display Appropriate Legal Notices, as required under+ * Section 5 of the GNU Affero General Public License version 3.+ *+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.+ ************************************************************************/++namespace Espo\Classes\Record\User;++use Espo\Core\Acl;+use Espo\Core\Record\Input\Data;+use Espo\Core\Record\Input\Filter;+use Espo\Entities\Team as TeamEntity;+use Espo\Entities\User;++/**+ * @noinspection PhpUnused+ */+class InputFilter implements Filter+{+ public function __construct(+ private User $user,+ private Acl $acl,+ ) {}++ public function filter(Data $data): void+ {+ if (!$this->user->isSuperAdmin()) {+ $data->clear('isSuperAdmin');+ }++ if (!$this->user->isAdmin() && !$this->acl->checkScope(TeamEntity::ENTITY_TYPE)) {+ $data->clear('defaultTeamId');+ }+ }+}diff --git a/application/Espo/Resources/metadata/recordDefs/User.json b/application/Espo/Resources/metadata/recordDefs/User.jsonindex 4141dc43ae..7df9200514 100644--- a/application/Espo/Resources/metadata/recordDefs/User.json+++ b/application/Espo/Resources/metadata/recordDefs/User.json@@ -12,6 +12,12 @@"userName","type"],+ "createInputFilterClassNameList": [+ "Espo\\Classes\\Record\\User\\InputFilter"+ ],+ "updateInputFilterClassNameList": [+ "Espo\\Classes\\Record\\User\\InputFilter"+ ],"outputFilterClassNameList": ["Espo\\Classes\\Record\\User\\OutputFilter"],diff --git a/application/Espo/Services/User.php b/application/Espo/Services/User.phpindex 399370dc87..3df03af525 100644--- a/application/Espo/Services/User.php+++ b/application/Espo/Services/User.php@@ -34,7 +34,6 @@ use Espo\Core\Di\LogSetter;use Espo\Core\Exceptions\Conflict;use Espo\Core\Exceptions\NotFound;use Espo\Core\Mail\Exceptions\SendingError;-use Espo\Entities\Team as TeamEntity;use Espo\Entities\User as UserEntity;use Espo\Core\Exceptions\BadRequest;use Espo\Core\Exceptions\Forbidden;@@ -91,21 +90,6 @@ class User extends Record implements LogAwarereturn $passwordHash->hash($password);}- protected function filterInput(stdClass $data): void- {- parent::filterInput($data);-- if (!$this->user->isSuperAdmin()) {- unset($data->isSuperAdmin);- }-- if (!$this->user->isAdmin()) {- if (!$this->acl->checkScope(TeamEntity::ENTITY_TYPE)) {- unset($data->defaultTeamId);- }- }- }-/*** @throws BadRequest*/