Skip to content

Commit

Permalink
feat: Implement internal sign page
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Apr 8, 2024
1 parent 5fbdd0f commit cf34c49
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
2 changes: 2 additions & 0 deletions appinfo/routes/routesPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// Pages - restricted
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#indexF', 'url' => '/f/', 'verb' => 'GET'],
['name' => 'page#signFPath', 'url' => '/f/sign/{uuid}/{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], 'postfix' => 'extra'],
['name' => 'page#signF', 'url' => '/f/sign/{uuid}', 'verb' => 'GET'],
['name' => 'page#indexFPath', 'url' => '/f/{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], 'postfix' => 'front'],
['name' => 'page#getPdfFile', 'url' => '/pdf/{uuid}', 'verb' => 'GET'],
['name' => 'page#resetPassword', 'url' => '/reset-password', 'verb' => 'GET'],
Expand Down
32 changes: 22 additions & 10 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,36 @@ public function indexFPath(): TemplateResponse {
return $this->index();
}

/**
* Show signature page
*/
#[NoAdminRequired]
#[NoCSRFRequired]
#[RequireSetupOk]
#[PublicPage]
#[RequireSignRequestUuid]
public function sign($uuid): TemplateResponse {
public function signF(string $uuid): TemplateResponse {
$this->initialState->provideInitialState('action', JSActions::ACTION_SIGN_INTERNAL);
return $this->index();
}

#[NoAdminRequired]
#[NoCSRFRequired]
#[RequireSetupOk]
#[PublicPage]
#[RequireSignRequestUuid]
public function signFPath(string $uuid): TemplateResponse {
$this->initialState->provideInitialState('action', JSActions::ACTION_SIGN_INTERNAL);
return $this->index();
}

#[NoAdminRequired]
#[NoCSRFRequired]
#[RequireSetupOk]
#[PublicPage]
#[RequireSignRequestUuid]
public function sign(string $uuid): TemplateResponse {
$this->initialState->provideInitialState('action', JSActions::ACTION_SIGN);
$this->initialState->provideInitialState('config',
$this->accountService->getConfig($this->userSession->getUser())
);
$this->initialState->provideInitialState('signer',
$this->signFileService->getSignerData(
$this->userSession->getUser(),
$this->getSignRequestEntity(),
)
);
$this->initialState->provideInitialState('filename', $this->getFileEntity()->getName());
$file = $this->fileService
->setFile($this->getFileEntity())
Expand All @@ -170,6 +181,7 @@ public function sign($uuid): TemplateResponse {
$this->initialState->provideInitialState('pdf',
$this->signFileService->getFileUrl('url', $this->getFileEntity(), $this->getNextcloudFile(), $uuid)
);
$this->initialState->provideInitialState('nodeId', $this->getFileEntity()->getNodeId());

Util::addScript(Application::APP_ID, 'libresign-external');
$response = new TemplateResponse(Application::APP_ID, 'external', [], TemplateResponse::RENDER_AS_BASE);
Expand Down
1 change: 1 addition & 0 deletions lib/Helper/JSActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class JSActions {
public const ACTION_CREATE_ACCOUNT = 1500;
public const ACTION_DO_NOTHING = 2000;
public const ACTION_SIGN = 2500;
public const ACTION_SIGN_INTERNAL = 2625;
public const ACTION_SIGN_ACCOUNT_FILE = 2750;
public const ACTION_SHOW_ERROR = 3000;
public const ACTION_SIGNED = 3500;
Expand Down

0 comments on commit cf34c49

Please sign in to comment.