Skip to content

Commit

Permalink
Merge pull request #26 from LibreCodeCoop/bugfix/prevent-error
Browse files Browse the repository at this point in the history
Bugfix: prevent errors
  • Loading branch information
vitormattos authored Aug 18, 2023
2 parents da0f9d0 + 31f6ced commit 7e8eb64
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Get access to important information about your company
```bash
# Group folders
occ app:enable --force groupfolders
occ group:add mycompany --display-name="My Company"

occ app:enable my_company
occ my-company:company:add --code local --name "My company" --domain local.localhost
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function index(string $path): TemplateResponse {
$signUuid = $libreSignFile->getUuid();
$this->initialState->provideInitialState('registration-form-sign-uuid', $signUuid);
} catch (LibresignException | NotFoundException $th) {
$this->initialState->provideInitialState('registration-form-filled', false);
}
}

Expand Down
16 changes: 8 additions & 8 deletions lib/Middleware/InjectionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use OCA\Forms\Controller\ApiController;
use OCA\MyCompany\AppInfo\Application;
use OCA\MyCompany\Backend\SystemGroupBackend;
use OCA\MyCompany\Service\CompanyService;
use OCA\MyCompany\Service\RegistrationService;
use OCA\Theming\Controller\ThemingController;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
Expand All @@ -32,6 +34,8 @@ public function __construct(
private IGroupManager $groupManager,
private IAppManager $appManager,
private IConfig $config,
private CompanyService $companyService,
private RegistrationService $registrationService,
) {
}

Expand Down Expand Up @@ -124,12 +128,10 @@ private function getImageFromDomain(Response $response): Response {
}

if ($type === 'logo') {
$companyService = \OC::$server->get(OCA\MyCompany\Service\CompanyService::class);
$file = $companyService->getThemeFile('core/img/logo.svg');
$file = $this->companyService->getThemeFile('core/img/logo.svg');
$mime = 'image/svg+xml';
} elseif ($type === 'background') {
$companyService = \OC::$server->get(OCA\MyCompany\Service\CompanyService::class);
$file = $companyService->getThemeFile('core/img/background.jpg');
$file = $this->companyService->getThemeFile('core/img/background.jpg');
$mime = 'image/jpg';
} else {
return new NotFoundResponse();
Expand Down Expand Up @@ -171,12 +173,10 @@ private function signRegistrationForm(Controller $controller, string $methodName
return;
}
$id = $this->request->getParam('formId');
$companyService = \OC::$server->get(OCA\MyCompany\Service\CompanyService::class);
$registrationFormId = $companyService->getRegistrationFormId();
$registrationFormId = $this->companyService->getRegistrationFormId();
if ($id !== $registrationFormId) {
return;
}
$registrationService = \OC::$server->get(OCA\MyCompany\Service\RegistrationService::class);
$registrationService->signForm();
$this->registrationService->signForm();
}
}
2 changes: 1 addition & 1 deletion lib/Service/CompanyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private function getThemeFolder(string $folderName): ISimpleFolder {

private function getGroupFolderIdFromCompanyCode(string $companyCode, string $type = ''): int {
if (!$this->groupManager->groupExists($companyCode)) {
throw new \Exception('Company not allowed to use this system');
throw new NotFoundException('Company not allowed to use this system');
}

$mountPointName = $companyCode . ($type ? '-' . $type : '');
Expand Down
4 changes: 2 additions & 2 deletions src/views/Registration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</NcEmptyContent>
<div class="flex">
<div class="list-items">
<NcButton v-if="!approved"
<NcButton v-if="!approved || !formFilled"
:wide="true"
@click="fillForm()">
<template #icon>
Expand All @@ -20,7 +20,7 @@
{{ t('my_company', 'Fill with new data') }}
</template>
</NcButton>
<NcButton v-if="approved || formSignUuid"
<NcButton v-else-if="approved || formSignUuid"
:wide="true"
@click="viewSigned()">
<template #icon>
Expand Down
6 changes: 6 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
</UndefinedInterfaceMethod>
</file>
<file src="lib/Middleware/InjectionMiddleware.php">
<InvalidTemplateParam>
<code><![CDATA[$response->addHeader('Content-Disposition', 'attachment; filename="' . $type . '"')]]></code>
<code><![CDATA[$response->addHeader('Content-Type', $mime)]]></code>
<code><![CDATA[$response->cacheFor(3600)]]></code>
<code><![CDATA[$response->setContentSecurityPolicy($csp)]]></code>
</InvalidTemplateParam>
<UndefinedClass>
<code>ApiController</code>
<code>ThemingController</code>
Expand Down

0 comments on commit 7e8eb64

Please sign in to comment.