• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 19878831952

03 Dec 2025 01:08AM UTC coverage: 41.576%. First build
19878831952

Pull #4464

github

web-flow
Merge a843e05d5 into da0973853
Pull Request #4464: refactor: attach document

117 of 302 new or added lines in 16 files covered. (38.74%)

5123 of 12322 relevant lines covered (41.58%)

4.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/Controller/PageController.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Controller;
10

11
use OCA\Libresign\AppInfo\Application;
12
use OCA\Libresign\Exception\LibresignException;
13
use OCA\Libresign\Helper\JSActions;
14
use OCA\Libresign\Helper\ValidateHelper;
15
use OCA\Libresign\Middleware\Attribute\PrivateValidation;
16
use OCA\Libresign\Middleware\Attribute\RequireSetupOk;
17
use OCA\Libresign\Middleware\Attribute\RequireSignRequestUuid;
18
use OCA\Libresign\Service\AccountService;
19
use OCA\Libresign\Service\FileService;
20
use OCA\Libresign\Service\IdentifyMethod\SignatureMethod\TokenService;
21
use OCA\Libresign\Service\IdentifyMethodService;
22
use OCA\Libresign\Service\RequestSignatureService;
23
use OCA\Libresign\Service\SessionService;
24
use OCA\Libresign\Service\SignerElementsService;
25
use OCA\Libresign\Service\SignFileService;
26
use OCA\Viewer\Event\LoadViewer;
27
use OCP\AppFramework\Db\DoesNotExistException;
28
use OCP\AppFramework\Http;
29
use OCP\AppFramework\Http\Attribute\AnonRateLimit;
30
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
31
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
32
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
33
use OCP\AppFramework\Http\Attribute\PublicPage;
34
use OCP\AppFramework\Http\ContentSecurityPolicy;
35
use OCP\AppFramework\Http\DataResponse;
36
use OCP\AppFramework\Http\FileDisplayResponse;
37
use OCP\AppFramework\Http\TemplateResponse;
38
use OCP\AppFramework\Services\IInitialState;
39
use OCP\EventDispatcher\IEventDispatcher;
40
use OCP\IAppConfig;
41
use OCP\IL10N;
42
use OCP\IRequest;
43
use OCP\IURLGenerator;
44
use OCP\IUserSession;
45
use OCP\Util;
46

47
class PageController extends AEnvironmentPageAwareController {
48
        public function __construct(
49
                IRequest $request,
50
                protected IUserSession $userSession,
51
                private SessionService $sessionService,
52
                private IInitialState $initialState,
53
                private AccountService $accountService,
54
                protected SignFileService $signFileService,
55
                protected RequestSignatureService $requestSignatureService,
56
                private SignerElementsService $signerElementsService,
57
                protected IL10N $l10n,
58
                private IdentifyMethodService $identifyMethodService,
59
                private IAppConfig $appConfig,
60
                private FileService $fileService,
61
                private ValidateHelper $validateHelper,
62
                private IEventDispatcher $eventDispatcher,
63
                private IURLGenerator $urlGenerator,
64
        ) {
65
                parent::__construct(
×
66
                        request: $request,
×
67
                        signFileService: $signFileService,
×
68
                        l10n: $l10n,
×
69
                        userSession: $userSession,
×
70
                );
×
71
        }
72

73
        /**
74
         * Index page
75
         *
76
         * @return TemplateResponse<Http::STATUS_OK, array{}>
77
         *
78
         * 200: OK
79
         */
80
        #[NoAdminRequired]
81
        #[NoCSRFRequired]
82
        #[RequireSetupOk(template: 'main')]
83
        #[FrontpageRoute(verb: 'GET', url: '/')]
84
        public function index(): TemplateResponse {
85
                $this->initialState->provideInitialState('config', $this->accountService->getConfig($this->userSession->getUser()));
×
86
                $this->initialState->provideInitialState('certificate_engine', $this->accountService->getCertificateEngineName());
×
87

88
                try {
89
                        $this->validateHelper->canRequestSign($this->userSession->getUser());
×
90
                        $this->initialState->provideInitialState('can_request_sign', true);
×
91
                } catch (LibresignException) {
×
92
                        $this->initialState->provideInitialState('can_request_sign', false);
×
93
                }
94

95
                $this->provideSignerSignatues();
×
96
                $this->initialState->provideInitialState('identify_methods', $this->identifyMethodService->getIdentifyMethodsSettings());
×
97
                $this->initialState->provideInitialState('legal_information', $this->appConfig->getValueString(Application::APP_ID, 'legal_information'));
×
98

99
                Util::addScript(Application::APP_ID, 'libresign-main');
×
100

101
                if (class_exists(LoadViewer::class)) {
×
102
                        $this->eventDispatcher->dispatchTyped(new LoadViewer());
×
103
                }
104

105
                $response = new TemplateResponse(Application::APP_ID, 'main');
×
106

107
                $policy = new ContentSecurityPolicy();
×
108
                $policy->allowEvalScript(true);
×
109
                $policy->addAllowedFrameDomain('\'self\'');
×
110
                $response->setContentSecurityPolicy($policy);
×
111

112
                return $response;
×
113
        }
114

115
        /**
116
         * Index page to authenticated users
117
         *
118
         * This router is used to be possible render pages with /f/, is a
119
         * workaround at frontend side to identify pages with authenticated accounts
120
         *
121
         * @return TemplateResponse<Http::STATUS_OK, array{}>
122
         *
123
         * 200: OK
124
         */
125
        #[NoAdminRequired]
126
        #[NoCSRFRequired]
127
        #[RequireSetupOk(template: 'main')]
128
        #[FrontpageRoute(verb: 'GET', url: '/f/')]
129
        public function indexF(): TemplateResponse {
130
                return $this->index();
×
131
        }
132

133
        /**
134
         * Incomplete page
135
         *
136
         * @return TemplateResponse<Http::STATUS_OK, array{}>
137
         *
138
         * 200: OK
139
         */
140
        #[NoAdminRequired]
141
        #[NoCSRFRequired]
142
        #[FrontpageRoute(verb: 'GET', url: '/f/incomplete')]
143
        public function incomplete(): TemplateResponse {
144
                Util::addScript(Application::APP_ID, 'libresign-main');
×
145
                $response = new TemplateResponse(Application::APP_ID, 'main');
×
146
                return $response;
×
147
        }
148

149
        /**
150
         * Incomplete page in full screen
151
         *
152
         * @return TemplateResponse<Http::STATUS_OK, array{}>
153
         *
154
         * 200: OK
155
         */
156
        #[PublicPage]
157
        #[NoCSRFRequired]
158
        #[FrontpageRoute(verb: 'GET', url: '/p/incomplete')]
159
        public function incompleteP(): TemplateResponse {
160
                Util::addScript(Application::APP_ID, 'libresign-main');
×
161
                $response = new TemplateResponse(Application::APP_ID, 'main', [], TemplateResponse::RENDER_AS_BASE);
×
162
                return $response;
×
163
        }
164

165
        /**
166
         * Main page to authenticated signer with a path
167
         *
168
         * The path is used only by frontend
169
         *
170
         * @param string $path The path that was sent from frontend
171
         * @return TemplateResponse<Http::STATUS_OK, array{}>
172
         *
173
         * 200: OK
174
         */
175
        #[NoAdminRequired]
176
        #[NoCSRFRequired]
177
        #[RequireSetupOk(template: 'main')]
178
        #[FrontpageRoute(verb: 'GET', url: '/f/{path}', requirements: ['path' => '.+'])]
179
        public function indexFPath(string $path): TemplateResponse {
180
                if (preg_match('/validation\/(?<uuid>[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/', $path, $matches)) {
×
181

182
                        try {
183
                                $this->initialState->provideInitialState('file_info',
×
184
                                        $this->fileService
×
185
                                                ->setFileByType('uuid', $matches['uuid'])
×
186
                                                ->setIdentifyMethodId($this->sessionService->getIdentifyMethodId())
×
187
                                                ->setHost($this->request->getServerHost())
×
188
                                                ->setMe($this->userSession->getUser())
×
189
                                                ->showVisibleElements()
×
190
                                                ->showSigners()
×
191
                                                ->showSettings()
×
192
                                                ->showMessages()
×
193
                                                ->showValidateFile()
×
194
                                                ->toArray()
×
195
                                );
×
196
                        } catch (LibresignException) {
×
197
                                throw new LibresignException(json_encode([
×
198
                                        'action' => JSActions::ACTION_DO_NOTHING,
×
199
                                        'errors' => [['message' => $this->l10n->t('Invalid UUID')]],
×
200
                                ]), Http::STATUS_NOT_FOUND);
×
201
                        }
NEW
202
                } elseif (preg_match('/sign\/(?<uuid>[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})/', $path, $matches)) {
×
203
                        try {
NEW
204
                                $signRequest = $this->signFileService->getSignRequestByUuid($matches['uuid']);
×
NEW
205
                                $file = $this->fileService
×
NEW
206
                                        ->setFile($this->signFileService->getFile($signRequest->getFileId()))
×
NEW
207
                                        ->setMe($this->userSession->getUser())
×
NEW
208
                                        ->setSignRequest($signRequest)
×
NEW
209
                                        ->showSettings()
×
NEW
210
                                        ->toArray();
×
NEW
211
                                $this->initialState->provideInitialState('needIdentificationDocuments', $file['settings']['needIdentificationDocuments'] ?? false);
×
NEW
212
                                $this->initialState->provideInitialState('identificationDocumentsWaitingApproval', $file['settings']['identificationDocumentsWaitingApproval'] ?? false);
×
NEW
213
                        } catch (\Throwable $e) {
×
NEW
214
                                throw new LibresignException(json_encode([
×
NEW
215
                                        'action' => JSActions::ACTION_DO_NOTHING,
×
NEW
216
                                        'errors' => [['message' => $this->l10n->t('Invalid UUID')]],
×
NEW
217
                                ]), Http::STATUS_NOT_FOUND);
×
218
                        }
219
                }
220
                return $this->index();
×
221
        }
222

223

224
        /**
225
         * Sign page to authenticated signer
226
         *
227
         * @param string $uuid Sign request uuid
228
         * @return TemplateResponse<Http::STATUS_OK, array{}>
229
         *
230
         * 200: OK
231
         */
232
        #[NoAdminRequired]
233
        #[NoCSRFRequired]
234
        #[RequireSetupOk]
235
        #[PublicPage]
236
        #[RequireSignRequestUuid]
237
        #[FrontpageRoute(verb: 'GET', url: '/f/sign/{uuid}')]
238
        public function signF(string $uuid): TemplateResponse {
239
                $this->initialState->provideInitialState('action', JSActions::ACTION_SIGN_INTERNAL);
×
240
                return $this->index();
×
241
        }
242

243
        /**
244
         * Sign page to authenticated signer with the path of file
245
         *
246
         * The path is used only by frontend
247
         *
248
         * @param string $uuid Sign request uuid
249
         * @return TemplateResponse<Http::STATUS_OK, array{}>
250
         *
251
         * 200: OK
252
         */
253
        #[NoAdminRequired]
254
        #[NoCSRFRequired]
255
        #[RequireSetupOk]
256
        #[PublicPage]
257
        #[RequireSignRequestUuid]
258
        #[FrontpageRoute(verb: 'GET', url: '/f/sign/{uuid}/{path}', requirements: ['path' => '.+'])]
259
        public function signFPath(string $uuid): TemplateResponse {
260
                $this->initialState->provideInitialState('action', JSActions::ACTION_SIGN_INTERNAL);
×
261
                return $this->index();
×
262
        }
263

264
        /**
265
         * Sign page to unauthenticated signer
266
         *
267
         * The path is used only by frontend
268
         *
269
         * @param string $uuid Sign request uuid
270
         * @return TemplateResponse<Http::STATUS_OK, array{}>
271
         *
272
         * 200: OK
273
         */
274
        #[NoAdminRequired]
275
        #[NoCSRFRequired]
276
        #[RequireSetupOk]
277
        #[PublicPage]
278
        #[RequireSignRequestUuid]
279
        #[FrontpageRoute(verb: 'GET', url: '/p/sign/{uuid}/{path}', requirements: ['path' => '.+'])]
280
        public function signPPath(string $uuid): TemplateResponse {
281
                return $this->sign($uuid);
×
282
        }
283

284
        /**
285
         * Sign page to unauthenticated signer
286
         *
287
         * The path is used only by frontend
288
         *
289
         * @param string $uuid Sign request uuid
290
         * @return TemplateResponse<Http::STATUS_OK, array{}>
291
         *
292
         * 200: OK
293
         */
294
        #[PrivateValidation]
295
        #[NoAdminRequired]
296
        #[NoCSRFRequired]
297
        #[RequireSetupOk]
298
        #[PublicPage]
299
        #[RequireSignRequestUuid]
300
        #[FrontpageRoute(verb: 'GET', url: '/p/sign/{uuid}')]
301
        public function sign(string $uuid): TemplateResponse {
302
                $this->initialState->provideInitialState('action', JSActions::ACTION_SIGN);
×
303
                $this->initialState->provideInitialState('config',
×
304
                        $this->accountService->getConfig($this->userSession->getUser())
×
305
                );
×
306
                $this->initialState->provideInitialState('filename', $this->getFileEntity()->getName());
×
307
                $file = $this->fileService
×
308
                        ->setFile($this->getFileEntity())
×
309
                        ->setHost($this->request->getServerHost())
×
310
                        ->setMe($this->userSession->getUser())
×
NEW
311
                        ->setSignerIdentified()
×
312
                        ->setIdentifyMethodId($this->sessionService->getIdentifyMethodId())
×
313
                        ->setSignRequest($this->getSignRequestEntity())
×
314
                        ->showVisibleElements()
×
315
                        ->showSigners()
×
NEW
316
                        ->showSettings()
×
317
                        ->toArray();
×
NEW
318
                $this->initialState->provideInitialState('config', [
×
NEW
319
                        'identificationDocumentsFlow' => $file['settings']['needIdentificationDocuments'] ?? false,
×
NEW
320
                ]);
×
NEW
321
                $this->initialState->provideInitialState('needIdentificationDocuments', $file['settings']['needIdentificationDocuments'] ?? false);
×
NEW
322
                $this->initialState->provideInitialState('identificationDocumentsWaitingApproval', $file['settings']['identificationDocumentsWaitingApproval'] ?? false);
×
323
                $this->initialState->provideInitialState('status', $file['status']);
×
324
                $this->initialState->provideInitialState('statusText', $file['statusText']);
×
325
                $this->initialState->provideInitialState('signers', $file['signers']);
×
326
                $this->initialState->provideInitialState('sign_request_uuid', $uuid);
×
327
                $this->provideSignerSignatues();
×
328
                $this->initialState->provideInitialState('token_length', TokenService::TOKEN_LENGTH);
×
329
                $this->initialState->provideInitialState('description', $this->getSignRequestEntity()->getDescription() ?? '');
×
330
                $this->initialState->provideInitialState('pdf',
×
331
                        $this->signFileService->getFileUrl('url', $this->getFileEntity(), $this->getNextcloudFile(), $uuid)
×
332
                );
×
333
                $this->initialState->provideInitialState('nodeId', $this->getFileEntity()->getNodeId());
×
334

335
                Util::addScript(Application::APP_ID, 'libresign-external');
×
336
                $response = new TemplateResponse(Application::APP_ID, 'external', [], TemplateResponse::RENDER_AS_BASE);
×
337

338
                $policy = new ContentSecurityPolicy();
×
339
                $policy->allowEvalScript(true);
×
340
                $response->setContentSecurityPolicy($policy);
×
341

342
                return $response;
×
343
        }
344

345
        private function provideSignerSignatues(): void {
346
                $signatures = [];
×
347
                if ($this->userSession->getUser()) {
×
348
                        $signatures = $this->signerElementsService->getUserElements($this->userSession->getUser()->getUID());
×
349
                } else {
350
                        $signatures = $this->signerElementsService->getElementsFromSessionAsArray();
×
351
                }
352
                $this->initialState->provideInitialState('user_signatures', $signatures);
×
353
        }
354

355
        /**
356
         * Show signature page
357
         *
358
         * @param string $uuid Sign request uuid
359
         * @return TemplateResponse<Http::STATUS_OK, array{}>
360
         *
361
         * 200: OK
362
         * 404: Invalid UUID
363
         */
364
        #[NoAdminRequired]
365
        #[NoCSRFRequired]
366
        #[RequireSetupOk]
367
        #[FrontpageRoute(verb: 'GET', url: '/p/id-docs/approve/{uuid}')]
368
        #[FrontpageRoute(verb: 'GET', url: '/p/id-docs/approve/{uuid}/{path}', requirements: ['path' => '.+'], postfix: 'private')]
369
        public function signIdDoc($uuid): TemplateResponse {
370
                try {
371
                        $fileEntity = $this->signFileService->getFileByUuid($uuid);
×
NEW
372
                        $this->signFileService->getIdDocById($fileEntity->getId());
×
373
                } catch (DoesNotExistException) {
×
374
                        throw new LibresignException(json_encode([
×
375
                                'action' => JSActions::ACTION_DO_NOTHING,
×
376
                                'errors' => [['message' => $this->l10n->t('Invalid UUID')]],
×
377
                        ]), Http::STATUS_NOT_FOUND);
×
378
                }
NEW
379
                $this->initialState->provideInitialState('action', JSActions::ACTION_SIGN_ID_DOC);
×
380
                $this->initialState->provideInitialState('config',
×
381
                        $this->accountService->getConfig($this->userSession->getUser())
×
382
                );
×
383
                $this->initialState->provideInitialState('signer',
×
384
                        $this->signFileService->getSignerData(
×
385
                                $this->userSession->getUser(),
×
386
                        )
×
387
                );
×
388
                $this->initialState->provideInitialState('identifyMethods',
×
389
                        $this->signFileService->getAvailableIdentifyMethodsFromSettings()
×
390
                );
×
391
                $this->initialState->provideInitialState('filename', $fileEntity->getName());
×
392
                $file = $this->fileService
×
393
                        ->setFile($fileEntity)
×
394
                        ->setHost($this->request->getServerHost())
×
395
                        ->setMe($this->userSession->getUser())
×
396
                        ->setIdentifyMethodId($this->sessionService->getIdentifyMethodId())
×
397
                        ->showVisibleElements()
×
398
                        ->showSigners()
×
399
                        ->toArray();
×
400
                $this->initialState->provideInitialState('fileId', $file['nodeId']);
×
401
                $this->initialState->provideInitialState('status', $file['status']);
×
402
                $this->initialState->provideInitialState('statusText', $file['statusText']);
×
403
                $this->initialState->provideInitialState('visibleElements', []);
×
404
                $this->initialState->provideInitialState('signers', []);
×
405
                $this->provideSignerSignatues();
×
406
                $signatureMethods = $this->identifyMethodService->getSignMethodsOfIdentifiedFactors($this->getSignRequestEntity()->getId());
×
407
                $this->initialState->provideInitialState('signature_methods', $signatureMethods);
×
408
                $this->initialState->provideInitialState('token_length', TokenService::TOKEN_LENGTH);
×
409
                $this->initialState->provideInitialState('description', '');
×
410
                $nextcloudFile = $this->signFileService->getNextcloudFile($fileEntity);
×
411
                $this->initialState->provideInitialState('pdf',
×
412
                        $this->signFileService->getFileUrl('url', $fileEntity, $nextcloudFile, $uuid)
×
413
                );
×
414

415
                Util::addScript(Application::APP_ID, 'libresign-external');
×
416
                $response = new TemplateResponse(Application::APP_ID, 'external', [], TemplateResponse::RENDER_AS_BASE);
×
417

418
                $policy = new ContentSecurityPolicy();
×
419
                $policy->allowEvalScript(true);
×
420
                $response->setContentSecurityPolicy($policy);
×
421

422
                return $response;
×
423
        }
424

425
        /**
426
         * Use UUID of file to get PDF
427
         *
428
         * @param string $uuid File uuid
429
         * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
430
         *
431
         * 200: OK
432
         * 401: Validation page not accessible if unauthenticated
433
         * 404: File not found
434
         */
435
        #[PrivateValidation]
436
        #[NoAdminRequired]
437
        #[NoCSRFRequired]
438
        #[RequireSetupOk]
439
        #[PublicPage]
440
        #[AnonRateLimit(limit: 30, period: 60)]
441
        #[FrontpageRoute(verb: 'GET', url: '/p/pdf/{uuid}')]
442
        public function getPdf($uuid) {
443
                try {
444
                        $file = $this->accountService->getPdfByUuid($uuid);
×
445
                } catch (DoesNotExistException) {
×
446
                        return new DataResponse([], Http::STATUS_NOT_FOUND);
×
447
                }
448

449
                return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $file->getMimeType()]);
×
450
        }
451

452
        /**
453
         * Use UUID of user to get PDF
454
         *
455
         * @param string $uuid Sign request uuid
456
         * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>
457
         *
458
         * 200: OK
459
         * 401: Validation page not accessible if unauthenticated
460
         */
461
        #[PrivateValidation]
462
        #[NoAdminRequired]
463
        #[NoCSRFRequired]
464
        #[RequireSignRequestUuid]
465
        #[PublicPage]
466
        #[RequireSetupOk]
467
        #[AnonRateLimit(limit: 30, period: 60)]
468
        #[FrontpageRoute(verb: 'GET', url: '/pdf/{uuid}')]
469
        public function getPdfFile($uuid): FileDisplayResponse {
470
                $file = $this->getNextcloudFile();
×
471
                return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $file->getMimeType()]);
×
472
        }
473

474
        /**
475
         * Show validation page
476
         *
477
         * @return TemplateResponse<Http::STATUS_OK, array{}>
478
         *
479
         * 200: OK
480
         * 401: Validation page not accessible if unauthenticated
481
         */
482
        #[PrivateValidation]
483
        #[NoAdminRequired]
484
        #[NoCSRFRequired]
485
        #[RequireSetupOk(template: 'validation')]
486
        #[PublicPage]
487
        #[AnonRateLimit(limit: 30, period: 60)]
488
        #[FrontpageRoute(verb: 'GET', url: '/p/validation')]
489
        public function validation(): TemplateResponse {
490
                if ($this->getFileEntity()) {
×
491
                        $this->initialState->provideInitialState('config',
×
492
                                $this->accountService->getConfig($this->userSession->getUser())
×
493
                        );
×
494
                        $this->initialState->provideInitialState('file', [
×
495
                                'uuid' => $this->getFileEntity()?->getUuid(),
×
496
                                'description' => $this->getSignRequestEntity()?->getDescription(),
×
497
                        ]);
×
498
                        $this->initialState->provideInitialState('filename', $this->getFileEntity()?->getName());
×
499
                        $this->initialState->provideInitialState('pdf',
×
500
                                $this->signFileService->getFileUrl('url', $this->getFileEntity(), $this->getNextcloudFile(), $this->request->getParam('uuid'))
×
501
                        );
×
502
                        $this->initialState->provideInitialState('signer',
×
503
                                $this->signFileService->getSignerData(
×
504
                                        $this->userSession->getUser(),
×
505
                                        $this->getSignRequestEntity(),
×
506
                                )
×
507
                        );
×
508
                }
509

510
                Util::addScript(Application::APP_ID, 'libresign-validation');
×
511
                $response = new TemplateResponse(Application::APP_ID, 'validation', [], TemplateResponse::RENDER_AS_BASE);
×
512

513
                return $response;
×
514
        }
515

516
        /**
517
         * Show validation page
518
         *
519
         * The path is used only by frontend
520
         *
521
         * @param string $uuid Sign request uuid
522
         * @return TemplateResponse<Http::STATUS_OK, array{}>
523
         *
524
         * 200: OK
525
         * 303: Redirected to validation page
526
         * 401: Validation page not accessible if unauthenticated
527
         */
528
        #[PrivateValidation]
529
        #[NoAdminRequired]
530
        #[NoCSRFRequired]
531
        #[RequireSetupOk]
532
        #[PublicPage]
533
        #[AnonRateLimit(limit: 30, period: 60)]
534
        #[FrontpageRoute(verb: 'GET', url: '/validation/{uuid}')]
535
        public function validationFileWithShortUrl(): TemplateResponse {
536
                return $this->validationFilePublic($this->request->getParam('uuid'));
×
537
        }
538

539
        /**
540
         * Show validation page
541
         *
542
         * @param string $uuid Sign request uuid
543
         * @return TemplateResponse<Http::STATUS_OK, array{}>
544
         *
545
         * 200: OK
546
         */
547
        #[NoAdminRequired]
548
        #[NoCSRFRequired]
549
        #[RequireSetupOk(template: 'main')]
550
        #[PublicPage]
551
        #[RequireSignRequestUuid]
552
        #[FrontpageRoute(verb: 'GET', url: '/reset-password')]
553
        public function resetPassword(): TemplateResponse {
554
                $this->initialState->provideInitialState('config',
×
555
                        $this->accountService->getConfig($this->userSession->getUser())
×
556
                );
×
557

558
                Util::addScript(Application::APP_ID, 'libresign-main');
×
559
                $response = new TemplateResponse(Application::APP_ID, 'reset_password');
×
560

561
                return $response;
×
562
        }
563

564
        /**
565
         * Public page to show validation for a specific file UUID
566
         *
567
         * @param string $uuid File uuid
568
         * @return TemplateResponse<Http::STATUS_OK, array{}>
569
         *
570
         * 200: OK
571
         * 401: Validation page not accessible if unauthenticated
572
         */
573
        #[PrivateValidation]
574
        #[NoAdminRequired]
575
        #[NoCSRFRequired]
576
        #[RequireSetupOk(template: 'validation')]
577
        #[PublicPage]
578
        #[AnonRateLimit(limit: 30, period: 60)]
579
        #[FrontpageRoute(verb: 'GET', url: '/p/validation/{uuid}')]
580
        public function validationFilePublic(string $uuid): TemplateResponse {
581
                try {
582
                        $this->signFileService->getFileByUuid($uuid);
×
583
                        $this->fileService->setFileByType('uuid', $uuid);
×
584
                } catch (DoesNotExistException) {
×
585
                        try {
586
                                $signRequest = $this->signFileService->getSignRequestByUuid($uuid);
×
587
                                $libresignFile = $this->signFileService->getFile($signRequest->getFileId());
×
588
                                $this->fileService->setFile($libresignFile);
×
589
                        } catch (DoesNotExistException) {
×
590
                                $this->initialState->provideInitialState('action', JSActions::ACTION_DO_NOTHING);
×
591
                                $this->initialState->provideInitialState('errors', [['message' => $this->l10n->t('Invalid UUID')]]);
×
592
                        }
593
                }
594
                if ($this->userSession->isLoggedIn()) {
×
595
                        $this->initialState->provideInitialState('config',
×
596
                                $this->accountService->getConfig($this->userSession->getUser())
×
597
                        );
×
598
                        $this->fileService->setMe($this->userSession->getUser());
×
599
                } else {
600
                        $this->initialState->provideInitialState('config',
×
601
                                $this->accountService->getConfig()
×
602
                        );
×
603
                }
604

605
                $this->initialState->provideInitialState('legal_information', $this->appConfig->getValueString(Application::APP_ID, 'legal_information'));
×
606

607
                $this->initialState->provideInitialState('file_info',
×
608
                        $this->fileService
×
609
                                ->setIdentifyMethodId($this->sessionService->getIdentifyMethodId())
×
610
                                ->setHost($this->request->getServerHost())
×
611
                                ->showVisibleElements()
×
612
                                ->showSigners()
×
613
                                ->showSettings()
×
614
                                ->showMessages()
×
615
                                ->showValidateFile()
×
616
                                ->toArray()
×
617
                );
×
618

619
                Util::addScript(Application::APP_ID, 'libresign-validation');
×
620
                if (class_exists(LoadViewer::class)) {
×
621
                        $this->eventDispatcher->dispatchTyped(new LoadViewer());
×
622
                }
623
                $response = new TemplateResponse(Application::APP_ID, 'validation', [], TemplateResponse::RENDER_AS_BASE);
×
624

625
                return $response;
×
626
        }
627
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc