Files
api/services/nginx/app/routes/moduleConfigRoute.php
T
Jepp9350 61de9cdb45 Add email configuration module and enable invoice PDF retrieval
Introduce an email configuration module to manage SMTP settings, including encryption, host, username, and more. Implement functionality for retrieving invoice PDFs, storing them, and providing secure download links. Added relevant endpoint, routes, and helper methods to support these features.
2025-02-10 18:07:51 +01:00

122 lines
4.8 KiB
PHP

<?php
namespace routes;
use classes\authentication;
use classes\economic;
use classes\email;
use classes\recaptcha;
use classes\response;
use classes\router;
use objects\logs_o;
use traits\route_t;
class moduleConfigRoute
{
use route_t;
public function run(): void
{
global /** @var response $response */
/** @var router $router */
$router, $response;
/** Economic config > GET */
$this->get('/economic/config', function () {
global $response;
$this->requirePermission('economic_config');
$user = (new authentication())->get_user();
if ($user) {
(new logs_o())->add('economic_config', 'global', 1, $user->id, 'ECONOMIC_CONFIG', 'Successfully fetched economic config');
$response->success(
(new economic())->config->getConfigRequest()
);
} else {
(new logs_o())->add('economic_config', 'global', 1, 0, 'ECONOMIC_CONFIG', 'No user found, or invalid session');
$response->error('Invalid session', 400);
}
});
/** Economic config > POST */
$this->post('/economic/config', function () {
global $response;
$this->requirePermission('economic_config');
$user = (new authentication())->get_user();
if ($user) {
(new logs_o())->add('economic_config', 'global', 1, $user->id, 'ECONOMIC_CONFIG', 'Successfully updated economic config');
$response->success(
(new economic())->config->postConfigRequest()
);
} else {
(new logs_o())->add('economic_config', 'global', 1, 0, 'ECONOMIC_CONFIG', 'No user found, or invalid session');
$response->error('Invalid session', 400);
}
});
/** reCAPTCHA config > GET */
$this->get('/reCAPTCHA/config', function () {
global $response;
$this->requirePermission('recaptcha_config');
$user = (new authentication())->get_user();
if ($user) {
(new logs_o())->add('recaptcha_config', 'global', 1, $user->id, 'RECAPTCHA_CONFIG', 'Successfully fetched recaptcha config');
$response->success(
(new recaptcha())->config->getConfigRequest()
);
} else {
(new logs_o())->add('recaptcha_config', 'global', 1, 0, 'RECAPTCHA_CONFIG', 'No user found, or invalid session');
$response->error('Invalid session', 400);
}
});
/** reCAPTCHA config > POST */
$this->post('/reCAPTCHA/config', function () {
global $response;
$this->requirePermission('recaptcha_config');
$user = (new authentication())->get_user();
if ($user) {
(new logs_o())->add('recaptcha_config', 'global', 1, $user->id, 'RECAPTCHA_CONFIG', 'Successfully updated recaptcha config');
$response->success(
(new recaptcha())->config->postConfigRequest()
);
} else {
(new logs_o())->add('recaptcha_config', 'global', 1, 0, 'RECAPTCHA_CONFIG', 'No user found, or invalid session');
$response->error('Invalid session', 400);
}
});
/** Email config > GET */
$this->get('/email/config', function () {
global $response;
$this->requirePermission('email_config');
$user = (new authentication())->get_user();
if ($user) {
(new logs_o())->add('email_config', 'global', 1, $user->id, 'EMAIL_CONFIG', 'Successfully fetched email config');
$response->success(
(new email())->config->getConfigRequest()
);
} else {
(new logs_o())->add('email_config', 'global', 1, 0, 'EMAIL_CONFIG', 'No user found, or invalid session');
$response->error('Invalid session', 400);
}
});
/** Email config > POST */
$this->post('/email/config', function () {
global $response;
$this->requirePermission('email_config');
$user = (new authentication())->get_user();
if ($user) {
(new logs_o())->add('email_config', 'global', 1, $user->id, 'EMAIL_CONFIG', 'Successfully updated email config');
$response->success(
(new email())->config->postConfigRequest()
);
} else {
(new logs_o())->add('email_config', 'global', 1, 0, 'EMAIL_CONFIG', 'No user found, or invalid session');
$response->error('Invalid session', 400);
}
});
}
}