public function index()
    {
        if (!userHasPermission('admin:captcha:settings:*')) {
            unauthorised();
        }

        $oDb                   = Factory::service('Database');
        $oInput                = Factory::service('Input');
        $oCaptchaDriverService = Factory::service('CaptchaDriver', 'nails/module-captcha');

        if ($oInput->post()) {

            //  Settings keys
            $sKeyCaptchaDriver = $oCaptchaDriverService->getSettingKey();

            //  Validation
            $oFormValidation = Factory::service('FormValidation');

            $oFormValidation->set_rules($sKeyCaptchaDriver, '', 'required');

            if ($oFormValidation->run()) {

                try {

                    $oDb->trans_begin();

                    //  Drivers
                    $oCaptchaDriverService->saveEnabled($oInput->post($sKeyCaptchaDriver));

                    $oDb->trans_commit();
                    $this->data['success'] = 'Captcha settings were saved.';

                } catch (\Exception $e) {
                    $oDb->trans_rollback();
                    $this->data['error'] = 'There was a problem saving settings. ' . $e->getMessage();
                }

            } else {

                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        // --------------------------------------------------------------------------

        //  Get data
        $this->data['settings']                = appSetting(null, 'nails/module-captcha', true);
        $this->data['captcha_drivers']         = $oCaptchaDriverService->getAll();
        $this->data['captcha_drivers_enabled'] = $oCaptchaDriverService->getEnabledSlug();

        Helper::loadView('index');
    }