<?php

namespace routes;

use classes\authentication;
use classes\backup_store;
use classes\economic;
use classes\email;
use classes\fxratesapi;
use classes\motorapi;
use classes\recaptcha;
use classes\response;
use classes\router;
use classes\stripe;
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' => 'Get economic config'
            ]
        );

        /** 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);
            }
        },
            [
                'economic_config' => 'Update economic config'
            ]
        );

        /** 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' => 'Get recaptcha config'
            ]
        );

        /** 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);
            }
        },
            [
                'recaptcha_config' => 'Update recaptcha config'
            ]
        );

        /** 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' => 'Get email config'
            ]
        );

        /** 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);
            }
        },
            [
                'email_config' => 'Update email config'
            ]
        );

        /** Email config > TEST */
        $this->post('/email/config/test', function () {
            global $response;
            $this->requirePermission('email_config');
            $user = (new authentication())->get_user();
            if ($user) {
                $test_recipient = $this->fromRequest('email');
                if (!$test_recipient) {
                    (new logs_o())->add('email_config', 'global', 1, $user->id, 'EMAIL_CONFIG', 'Test email recipient not set');
                    $response->error('Test email recipient not set', 400);
                }
                // Check if the test recipient is a valid email
                if (!filter_var($test_recipient, FILTER_VALIDATE_EMAIL)) {
                    (new logs_o())->add('email_config', 'global', 1, $user->id, 'EMAIL_CONFIG', 'Invalid test email recipient');
                    $response->error('Invalid test email recipient', 400);
                }
                // Log the incident
                (new logs_o())->add('email_config', 'global', 1, $user->id, 'EMAIL_CONFIG', 'Successfully tested email config');
                $response->success(
                    (new email())->testConfigRequest($test_recipient)
                );
            } 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' => 'Test email config'
            ]
        );

        $this->get('/backups/config', function () {
            global $response;
            $this->requirePermission('backups_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('backups_config', 'global', 1, $user->id, 'BACKUPS_CONFIG', 'Successfully fetched backups config');
                $response->success(
                    (new backup_store())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('backups_config', 'global', 1, 0, 'BACKUPS_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'backups_config' => 'Get backups config'
            ]
        );

        $this->post('/backups/config', function () {
            global $response;
            $this->requirePermission('backups_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('backups_config', 'global', 1, $user->id, 'BACKUPS_CONFIG', 'Successfully updated backups config');
                $response->success(
                    (new backup_store())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('backups_config', 'global', 1, 0, 'BACKUPS_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'backups_config' => 'Update backups config'
            ]
        );

        /** MotorAPI config > GET */
        $this->get('/motorapi/config', function () {
            global $response;
            $this->requirePermission('motorapi_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('motorapi_config', 'global', 1, $user->id, 'MOTORAPI_CONFIG', 'Successfully fetched motorapi config');
                $response->success(
                    (new motorapi())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('motorapi_config', 'global', 1, 0, 'MOTORAPI_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'motorapi_config' => 'Get motorapi config'
            ]
        );

        /** MotorAPI config > POST */
        $this->post('/motorapi/config', function () {
            global $response;
            $this->requirePermission('motorapi_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('motorapi_config', 'global', 1, $user->id, 'MOTORAPI_CONFIG', 'Successfully updated motorapi config');
                $response->success(
                    (new motorapi())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('motorapi_config', 'global', 1, 0, 'MOTORAPI_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'motorapi_config' => 'Update motorapi config'
            ]
        );

        /** Stripe config > GET */
        $this->get('/stripe/config', function () {
            global $response;
            $this->requirePermission('stripe_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('stripe_config', 'global', 1, $user->id, 'STRIPE_CONFIG', 'Successfully fetched stripe config');
                $response->success(
                    (new stripe())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('stripe_config', 'global', 1, 0, 'STRIPE_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'stripe_config' => 'Get stripe config'
            ]
        );

        /** Stripe config > POST */
        $this->post('/stripe/config', function () {
            global $response;
            $this->requirePermission('stripe_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('stripe_config', 'global', 1, $user->id, 'STRIPE_CONFIG', 'Successfully updated stripe config');
                $response->success(
                    (new stripe())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('stripe_config', 'global', 1, 0, 'STRIPE_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'stripe_config' => 'Update stripe config'
            ]
        );

        /** FXRatesAPI config > GET */
        $this->get('/fxratesapi/config', function () {
            global $response;
            $this->requirePermission('fxratesapi_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('fxratesapi_config', 'global', 1, $user->id, 'FXRATESAPI_CONFIG', 'Successfully fetched fxratesapi config');
                $response->success(
                    (new fxratesapi())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('fxratesapi_config', 'global', 1, 0, 'FXRATESAPI_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'fxratesapi_config' => 'Get fxratesapi config'
            ]
        );
        /** FXRatesAPI config > POST */
        $this->post('/fxratesapi/config', function () {
            global $response;
            $this->requirePermission('fxratesapi_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('fxratesapi_config', 'global', 1, $user->id, 'FXRATESAPI_CONFIG', 'Successfully updated fxratesapi config');
                $response->success(
                    (new fxratesapi())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('fxratesapi_config', 'global', 1, 0, 'FXRATESAPI_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'fxratesapi_config' => 'Update fxratesapi config'
            ]
        );
        /** GatewayAPI config > GET */
        $this->get('/gatewayapi/config', function () {
            global $response;
            $this->requirePermission('gatewayapi_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('gatewayapi_config', 'global', 1, $user->id, 'GATEWAYAPI_CONFIG', 'Successfully fetched gatewayapi config');
                $response->success(
                    (new \classes\gatewayapi())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('gatewayapi_config', 'global', 1, 0, 'GATEWAYAPI_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'gatewayapi_config' => 'Get gatewayapi config'
            ]
        );
        /** GatewayAPI config > POST */
        $this->post('/gatewayapi/config', function () {
            global $response;
            $this->requirePermission('gatewayapi_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('gatewayapi_config', 'global', 1, $user->id, 'GATEWAYAPI_CONFIG', 'Successfully updated gatewayapi config');
                $response->success(
                    (new \classes\gatewayapi())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('gatewayapi_config', 'global', 1, 0, 'GATEWAYAPI_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'gatewayapi_config' => 'Update gatewayapi config'
            ]
        );

        /** XLVask config > GET */
        $this->get('/xlvask/config', function () {
            global $response;
            $this->requirePermission('xlvask_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('xlvask_config', 'global', 1, $user->id, 'XLVASK_CONFIG', 'Successfully fetched xlvask config');
                $response->success(
                    (new \classes\xlvask())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('xlvask_config', 'global', 1, 0, 'XLVASK_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'xlvask_config' => 'Get xlvask config'
            ]
        );
        /** XLVask config > POST */
        $this->post('/xlvask/config', function () {
            global $response;
            $this->requirePermission('xlvask_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('xlvask_config', 'global', 1, $user->id, 'XLVASK_CONFIG', 'Successfully updated xlvask config');
                $response->success(
                    (new \classes\xlvask())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('xlvask_config', 'global', 1, 0, 'XLVASK_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'xlvask_config' => 'Update xlvask config'
            ]
        );

        /** Entra config > GET */
        $this->get('/entra/config', function () {
            global $response;
            $this->requirePermission('entra_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('entra_config', 'global', 1, $user->id, 'ENTRA_CONFIG', 'Successfully fetched entra config');
                $response->success(
                    (new \classes\entra())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('entra_config', 'global', 1, 0, 'ENTRA_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'entra_config' => 'Get entra config'
            ]
        );
        /** Entra config > POST */
        $this->post('/entra/config', function () {
            global $response;
            $this->requirePermission('entra_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('entra_config', 'global', 1, $user->id, 'ENTRA_CONFIG', 'Successfully updated entra config');
                $response->success(
                    (new \classes\entra())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('entra_config', 'global', 1, 0, 'ENTRA_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'entra_config' => 'Update entra config'
            ]
        );
        /** Limble config > GET */
        $this->get('/limble/config', function () {
            global $response;
            $this->requirePermission('modules_limble_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('limble_config', 'global', 1, $user->id, 'LIMBLE_CONFIG', 'Successfully fetched limble config');
                $response->success(
                    (new \classes\limble())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('limble_config', 'global', 1, 0, 'LIMBLE_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_limble_config' => 'Get limble config'
            ]
        );
        /** Limble config > POST */
        $this->post('/limble/config', function () {
            global $response;
            $this->requirePermission('modules_limble_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('limble_config', 'global', 1, $user->id, 'LIMBLE_CONFIG', 'Successfully updated limble config');
                $response->success(
                    (new \classes\limble())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('limble_config', 'global', 1, 0, 'LIMBLE_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_limble_config' => 'Update limble config'
            ]
        );
        /** OcrSpace config > GET */
        $this->get('/ocrspace/config', function () {
            global $response;
            $this->requirePermission('modules_ocrspace_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('ocrspace_config', 'global', 1, $user->id, 'OCRSPACE_CONFIG', 'Successfully fetched ocrspace config');
                $response->success(
                    (new \classes\ocr_space())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('ocrspace_config', 'global', 1, 0, 'OCRSPACE_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_ocrspace_config' => 'Get ocrspace config'
            ]
        );
        /** OcrSpace config > POST */
        $this->post('/ocrspace/config', function () {
            global $response;
            $this->requirePermission('modules_ocrspace_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('ocrspace_config', 'global', 1, $user->id, 'OCRSPACE_CONFIG', 'Successfully updated ocrspace config');
                $response->success(
                    (new \classes\ocr_space())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('ocrspace_config', 'global', 1, 0, 'OCRSPACE_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_ocrspace_config' => 'Update ocrspace config'
            ]
        );
        /** OpenAI config > GET */
        $this->get('/openai/config', function () {
            global $response;
            $this->requirePermission('modules_openai_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('openai_config', 'global', 1, $user->id, 'OPENAI_CONFIG', 'Successfully fetched openai config');
                $response->success(
                    (new \classes\openai())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('openai_config', 'global', 1, 0, 'OPENAI_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_openai_config' => 'Get openai config'
            ]
        );
        /** OpenAI config > POST */
        $this->post('/openai/config', function () {
            global $response;
            $this->requirePermission('modules_openai_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('openai_config', 'global', 1, $user->id, 'OPENAI_CONFIG', 'Successfully updated openai config');
                $response->success(
                    (new \classes\openai())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('openai_config', 'global', 1, 0, 'OPENAI_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_openai_config' => 'Update openai config'
            ]
        );
        /** LicensePlateRecognizer config > GET */
        $this->get('/licenseplaterecognizer/config', function () {
            global $response;
            $this->requirePermission('modules_licenseplaterecognizer_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('licenseplaterecognizer_config', 'global', 1, $user->id, 'LICENSEPLATERECOGNIZER_CONFIG', 'Successfully fetched licenseplaterecognizer config');
                $response->success(
                    (new \classes\licenseplaterecognizer())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('licenseplaterecognizer_config', 'global', 1, 0, 'LICENSEPLATERECOGNIZER_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_licenseplaterecognizer_config' => 'Get licenseplaterecognizer config'
            ]
        );
        /** LicensePlateRecognizer config > POST */
        $this->post('/licenseplaterecognizer/config', function () {
            global $response;
            $this->requirePermission('modules_licenseplaterecognizer_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('licenseplaterecognizer_config', 'global', 1, $user->id, 'LICENSEPLATERECOGNIZER_CONFIG', 'Successfully updated licenseplaterecognizer config');
                $response->success(
                    (new \classes\licenseplaterecognizer())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('licenseplaterecognizer_config', 'global', 1, 0, 'LICENSEPLATERECOGNIZER_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_licenseplaterecognizer_config' => 'Update licenseplaterecognizer config'
            ]
        );
        /** Virkdata config > GET */
        $this->get('/virkdata/config', function () {
            global $response;
            $this->requirePermission('modules_virkdata_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('virkdata_config', 'global', 1, $user->id, 'VIRKDATA_CONFIG', 'Successfully fetched virkdata config');
                $response->success(
                    (new \classes\virkdata())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('virkdata_config', 'global', 1, 0, 'VIRKDATA_CONFIG', 'No user found, or invalid session');
            }
        },
            [
                'modules_virkdata_config' => 'Get virkdata config'
            ]
        );
        /** Virkdata config > POST */
        $this->post('/virkdata/config', function () {
            global $response;
            $this->requirePermission('modules_virkdata_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('virkdata_config', 'global', 1, $user->id, 'VIRKDATA_CONFIG', 'Successfully updated virkdata config');
                $response->success(
                    (new \classes\virkdata())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('virkdata_config', 'global', 1, 0, 'VIRKDATA_CONFIG', 'No user found, or invalid session');
                $response->error('Invalid session', 400);
            }
        },
            [
                'modules_virkdata_config' => 'Update virkdata config'
            ]
        );
        /** Shelly config -> GET */
        $this->get('/shelly/config', function () {
            global $response;
            $this->requirePermission('modules_shelly_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('shelly_config', 'global', 1, $user->id, 'SHELLY_CONFIG', 'Successfully fetched shelly config');
                $response->success(
                    (new \classes\shelly())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('shelly_config', 'global', 1, 0, 'VIRKDATA_CONFIG', 'No user found, or invalid session');
            }
        },
            [
                'modules_shelly_config' => 'Get shelly config'
            ]
        );
        $this->post('/shelly/config', function () {
            global $response;
            $this->requirePermission('modules_shelly_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('shelly_config', 'global', 1, $user->id, 'SHELLY_CONFIG', 'Successfully updated shelly config');
                $response->success(
                    (new \classes\shelly())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('shelly_config', 'global', 1, 0, 'SHELLY_CONFIG', 'No user found, or invalid session');
            }
        });
        /** Self-Serve config -> GET */
        $this->get('/selfserve/config', function () {
            global $response;
            $this->requirePermission('modules_selfserve_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('selfserve_config', 'global', 1, $user->id, 'SELFSERVE_CONFIG', 'Successfully fetched self-serve config');
                $response->success(
                    (new \classes\selfserve())->config->getConfigRequest()
                );
            } else {
                (new logs_o())->add('selfserve_config', 'global', 1, 0, 'SELFSERVE_CONFIG', 'No user found, or invalid session');
            }
        },
            [
                'modules_selfserve_config' => 'Get self-serve config'
            ]
        );
        $this->post('/selfserve/config', function () {
            global $response;
            $this->requirePermission('modules_selfserve_config');
            $user = (new authentication())->get_user();
            if ($user) {
                (new logs_o())->add('selfserve_config', 'global', 1, $user->id, 'SELFSERVE_CONFIG', 'Successfully updated self-serve config');
                $response->success(
                    (new \classes\selfserve())->config->postConfigRequest()
                );
            } else {
                (new logs_o())->add('selfserve_config', 'global', 1, 0, 'SELFSERVE_CONFIG', 'No user found, or invalid session');
            }
        });
    }
}