ref
This commit is contained in:
@@ -29,15 +29,13 @@
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use Espo\Services\CurrencyRate as Service;
|
||||
|
||||
use Espo\Tools\Currency\RateService as Service;
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class CurrencyRate
|
||||
{
|
||||
private $service;
|
||||
private Service $service;
|
||||
|
||||
public function __construct(Service $service)
|
||||
{
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use Espo\Services\Language as Service;
|
||||
use Espo\Tools\App\LanguageService as Service;
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
class I18n
|
||||
{
|
||||
private $service;
|
||||
private Service $service;
|
||||
|
||||
public function __construct(Service $service)
|
||||
{
|
||||
|
||||
@@ -29,12 +29,14 @@
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
use Espo\Services\UserSecurity as Service;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Tools\UserSecurity\Service as Service;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
@@ -42,10 +44,12 @@ use stdClass;
|
||||
|
||||
class UserSecurity
|
||||
{
|
||||
private $service;
|
||||
|
||||
private $user;
|
||||
private Service $service;
|
||||
private User $user;
|
||||
|
||||
/**
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function __construct(Service $service, User $user)
|
||||
{
|
||||
$this->service = $service;
|
||||
@@ -59,6 +63,11 @@ class UserSecurity
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function getActionRead(Request $request): stdClass
|
||||
{
|
||||
$id = $request->getRouteParam('id');
|
||||
@@ -74,6 +83,12 @@ class UserSecurity
|
||||
return $this->service->read($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionGetTwoFactorUserSetupData(Request $request): stdClass
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
@@ -91,6 +106,11 @@ class UserSecurity
|
||||
return $this->service->getTwoFactorUserSetupData($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function putActionUpdate(Request $request): stdClass
|
||||
{
|
||||
$id = $request->getRouteParam('id');
|
||||
|
||||
@@ -41,13 +41,10 @@ use Espo\Entities\User;
|
||||
|
||||
class TwoFactorSms
|
||||
{
|
||||
private $util;
|
||||
|
||||
private $user;
|
||||
|
||||
private $entityManager;
|
||||
|
||||
private $config;
|
||||
private Util $util;
|
||||
private User $user;
|
||||
private EntityManager $entityManager;
|
||||
private Config $config;
|
||||
|
||||
public function __construct(Util $util, User $user, EntityManager $entityManager, Config $config)
|
||||
{
|
||||
|
||||
+6
-8
@@ -27,19 +27,17 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Services;
|
||||
namespace Espo\Tools\App;
|
||||
|
||||
use Espo\Core\Utils\Language as LanguageUtil;
|
||||
|
||||
use Espo\Core\{
|
||||
Acl,
|
||||
Container,
|
||||
Utils\Metadata,
|
||||
};
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Container;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
class Language
|
||||
class LanguageService
|
||||
{
|
||||
private Metadata $metadata;
|
||||
private Acl $acl;
|
||||
@@ -58,7 +56,7 @@ class Language
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
// TODO use proxy
|
||||
// @todo Use proxy.
|
||||
protected function getDefaultLanguage(): LanguageUtil
|
||||
{
|
||||
/** @var LanguageUtil */
|
||||
+27
-22
@@ -27,40 +27,41 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Services;
|
||||
namespace Espo\Tools\Currency;
|
||||
|
||||
use Espo\Core\Exceptions\{
|
||||
BadRequest,
|
||||
Forbidden,
|
||||
};
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
use Espo\Core\{
|
||||
DataManager,
|
||||
Utils\Config,
|
||||
Utils\Config\ConfigWriter,
|
||||
Acl,
|
||||
};
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\DataManager;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\ConfigWriter;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class CurrencyRate
|
||||
class RateService
|
||||
{
|
||||
private $config;
|
||||
private Config $config;
|
||||
private ConfigWriter $configWriter;
|
||||
private DataManager $dataManager;
|
||||
private Acl $acl;
|
||||
|
||||
private $configWriter;
|
||||
|
||||
private $dataManager;
|
||||
|
||||
private $acl;
|
||||
|
||||
public function __construct(Config $config, ConfigWriter $configWriter, DataManager $dataManager, Acl $acl)
|
||||
{
|
||||
public function __construct(
|
||||
Config $config,
|
||||
ConfigWriter $configWriter,
|
||||
DataManager $dataManager,
|
||||
Acl $acl
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->configWriter = $configWriter;
|
||||
$this->dataManager = $dataManager;
|
||||
$this->acl = $acl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function get(): stdClass
|
||||
{
|
||||
if (!$this->acl->check('Currency')) {
|
||||
@@ -76,6 +77,11 @@ class CurrencyRate
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
*/
|
||||
public function set(stdClass $rates): stdClass
|
||||
{
|
||||
if (!$this->acl->check('Currency')) {
|
||||
@@ -119,7 +125,6 @@ class CurrencyRate
|
||||
$this->configWriter->set('currencyRates', $rates);
|
||||
|
||||
$this->configWriter->save();
|
||||
|
||||
$this->dataManager->rebuildDatabase([]);
|
||||
|
||||
return (object) (
|
||||
+16
-18
@@ -27,7 +27,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Services;
|
||||
namespace Espo\Tools\UserSecurity;
|
||||
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
@@ -40,27 +40,21 @@ use Espo\Entities\UserData;
|
||||
|
||||
use Espo\Repositories\UserData as UserDataRepository;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\Config,
|
||||
Authentication\LoginFactory,
|
||||
Authentication\TwoFactor\UserSetupFactory as TwoFactorUserSetupFactory,
|
||||
Authentication\Login\Data as LoginData,
|
||||
Api\RequestNull,
|
||||
};
|
||||
use Espo\Core\Api\RequestNull;
|
||||
use Espo\Core\Authentication\Login\Data as LoginData;
|
||||
use Espo\Core\Authentication\LoginFactory;
|
||||
use Espo\Core\Authentication\TwoFactor\UserSetupFactory as TwoFactorUserSetupFactory;
|
||||
use Espo\Core\Utils\Config;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class UserSecurity
|
||||
class Service
|
||||
{
|
||||
private $entityManager;
|
||||
|
||||
private $user;
|
||||
|
||||
private $config;
|
||||
|
||||
private $authLoginFactory;
|
||||
|
||||
private $twoFactorUserSetupFactory;
|
||||
private EntityManager $entityManager;
|
||||
private User $user;
|
||||
private Config $config;
|
||||
private LoginFactory $authLoginFactory;
|
||||
private TwoFactorUserSetupFactory $twoFactorUserSetupFactory;
|
||||
|
||||
public function __construct(
|
||||
EntityManager $entityManager,
|
||||
@@ -76,6 +70,10 @@ class UserSecurity
|
||||
$this->twoFactorUserSetupFactory = $twoFactorUserSetupFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Forbidden
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function read(string $id): stdClass
|
||||
{
|
||||
if (!$this->user->isAdmin() && $id !== $this->user->getId()) {
|
||||
Reference in New Issue
Block a user