mirror of
https://github.com/LibreSign/libresign.git
synced 2025-12-17 21:12:16 +01:00
Update default signature flow from 'parallel' to 'none' in page controller, template loader, admin settings, and settings view. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\Libresign\Files;
|
|
|
|
use OCA\Files\Event\LoadSidebar;
|
|
use OCA\Libresign\AppInfo\Application;
|
|
use OCA\Libresign\Exception\LibresignException;
|
|
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
|
|
use OCA\Libresign\Helper\ValidateHelper;
|
|
use OCA\Libresign\Service\AccountService;
|
|
use OCA\Libresign\Service\IdentifyMethodService;
|
|
use OCP\AppFramework\Services\IInitialState;
|
|
use OCP\EventDispatcher\Event;
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
|
use OCP\EventDispatcher\IEventListener;
|
|
use OCP\IAppConfig;
|
|
use OCP\IRequest;
|
|
use OCP\IUserSession;
|
|
|
|
/**
|
|
* @template-implements IEventListener<Event>
|
|
*/
|
|
class TemplateLoader implements IEventListener {
|
|
public function __construct(
|
|
private IRequest $request,
|
|
private IUserSession $userSession,
|
|
private AccountService $accountService,
|
|
private IInitialState $initialState,
|
|
private ValidateHelper $validateHelper,
|
|
private IdentifyMethodService $identifyMethodService,
|
|
private CertificateEngineFactory $certificateEngineFactory,
|
|
private IAppConfig $appConfig,
|
|
) {
|
|
}
|
|
|
|
public static function register(IEventDispatcher $dispatcher): void {
|
|
$dispatcher->addServiceListener(LoadSidebar::class, self::class);
|
|
}
|
|
|
|
#[\Override]
|
|
public function handle(Event $event): void {
|
|
if (!($event instanceof LoadSidebar)) {
|
|
return;
|
|
}
|
|
$this->initialState->provideInitialState(
|
|
'certificate_ok',
|
|
$this->certificateEngineFactory->getEngine()->isSetupOk()
|
|
);
|
|
|
|
$this->initialState->provideInitialState(
|
|
'identify_methods',
|
|
$this->identifyMethodService->getIdentifyMethodsSettings()
|
|
);
|
|
|
|
$this->initialState->provideInitialState(
|
|
'signature_flow',
|
|
$this->appConfig->getValueString(Application::APP_ID, 'signature_flow', \OCA\Libresign\Enum\SignatureFlow::NONE->value)
|
|
);
|
|
|
|
try {
|
|
$this->validateHelper->canRequestSign($this->userSession->getUser());
|
|
$this->initialState->provideInitialState('can_request_sign', true);
|
|
} catch (LibresignException) {
|
|
$this->initialState->provideInitialState('can_request_sign', false);
|
|
}
|
|
}
|
|
}
|