Skip to content

Commit ad8c323

Browse files
committed
refactor(policy): resolve identification_documents via PolicyService
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 602b5f7 commit ad8c323

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

lib/Service/AccountService.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
use OCA\Libresign\Helper\FileUploadHelper;
2727
use OCA\Libresign\Helper\ValidateHelper;
2828
use OCA\Libresign\Service\Crl\CrlService;
29+
use OCA\Libresign\Service\Policy\PolicyService;
2930
use OCA\Libresign\Service\Policy\PolicyAuthorizationService;
31+
use OCA\Libresign\Service\Policy\Provider\IdentificationDocuments\IdentificationDocumentsPolicy;
32+
use OCA\Libresign\Service\Policy\Provider\IdentificationDocuments\IdentificationDocumentsPolicyValue;
3033
use OCA\Libresign\Service\Policy\RequestSignAuthorizationService;
3134
use OCA\Settings\Mailer\NewUserMailHelper;
3235
use OCP\Accounts\IAccountManager;
@@ -76,6 +79,7 @@ public function __construct(
7679
private Pkcs12Handler $pkcs12Handler,
7780
private IGroupManager $groupManager,
7881
private PolicyAuthorizationService $policyAuthorizationService,
82+
private PolicyService $policyService,
7983
private IdDocsService $idDocsService,
8084
private SignerElementsService $signerElementsService,
8185
private UserElementMapper $userElementMapper,
@@ -198,8 +202,10 @@ public function getCertificateEngineName(): string {
198202
* @return array<string, mixed>
199203
*/
200204
public function getConfig(?IUser $user = null): array {
201-
202-
$info['identificationDocumentsFlow'] = $this->appConfig->getValueBool(Application::APP_ID, 'identification_documents', false);
205+
$resolvedIdentificationDocuments = $user
206+
? $this->policyService->resolveForUser(IdentificationDocumentsPolicy::KEY, $user)
207+
: $this->policyService->resolve(IdentificationDocumentsPolicy::KEY);
208+
$info['identificationDocumentsFlow'] = IdentificationDocumentsPolicyValue::normalize($resolvedIdentificationDocuments->getEffectiveValue(), false);
203209
$info['hasSignatureFile'] = $this->hasSignatureFile($user);
204210
$info['phoneNumber'] = $this->getPhoneNumber($user);
205211
$info['isApprover'] = $this->validateHelper->userCanApproveValidationDocuments($user, false);

lib/Settings/Admin.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use OCA\Libresign\Service\FooterService;
1818
use OCA\Libresign\Service\IdentifyMethodService;
1919
use OCA\Libresign\Service\Policy\PolicyService;
20+
use OCA\Libresign\Service\Policy\Provider\IdentificationDocuments\IdentificationDocumentsPolicy;
21+
use OCA\Libresign\Service\Policy\Provider\IdentificationDocuments\IdentificationDocumentsPolicyValue;
2022
use OCA\Libresign\Service\SignatureBackgroundService;
2123
use OCA\Libresign\Service\SignatureTextService;
2224
use OCP\AppFramework\Http\ContentSecurityPolicy;
@@ -104,7 +106,11 @@ public function getForm(): TemplateResponse {
104106
]);
105107
$this->initialState->provideInitialState('signing_mode', $this->getSigningModeInitialState());
106108
$this->initialState->provideInitialState('worker_type', $this->getWorkerTypeInitialState());
107-
$this->initialState->provideInitialState('identification_documents', $this->appConfig->getValueBool(Application::APP_ID, 'identification_documents', false));
109+
$resolvedIdentificationDocuments = $this->policyService->resolve(IdentificationDocumentsPolicy::KEY);
110+
$this->initialState->provideInitialState(
111+
'identification_documents',
112+
IdentificationDocumentsPolicyValue::normalize($resolvedIdentificationDocuments->getEffectiveValue(), false),
113+
);
108114
$this->initialState->provideInitialState('approval_group', $this->appConfig->getValueArray(Application::APP_ID, 'approval_group', ['admin']));
109115
$this->initialState->provideInitialState('envelope_enabled', $this->appConfig->getValueBool(Application::APP_ID, 'envelope_enabled', true));
110116
$this->initialState->provideInitialState('parallel_workers', $this->appConfig->getValueString(Application::APP_ID, 'parallel_workers', '4'));

0 commit comments

Comments
 (0)