From cc267b56eb8fee810c62388a6f4fcc861856191b Mon Sep 17 00:00:00 2001 From: FrancisTicgal Date: Fri, 16 Feb 2024 13:34:00 +0100 Subject: [PATCH] check credentials dot --- inc/config.class.php | 3 +- inc/secret.class.php | 6 ++- templates/config.html.twig | 101 +++++++++++++++++++------------------ 3 files changed, 58 insertions(+), 52 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index 7050397..8082ab3 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -127,7 +127,8 @@ public static function showConfigForm(): bool $template = "@onetimesecret/config.html.twig"; $template_options = [ 'item' => $config, - 'lifetimes' => $lifetimes + 'lifetimes' => $lifetimes, + 'conn' => PluginOnetimesecretSecret::authentication() ]; TemplateRenderer::getInstance()->display($template, $template_options); diff --git a/inc/secret.class.php b/inc/secret.class.php index ad083a1..e795752 100644 --- a/inc/secret.class.php +++ b/inc/secret.class.php @@ -41,9 +41,9 @@ class PluginOnetimesecretSecret extends CommonDBTM /** * authentication * - * @return void + * @return array */ - public static function authentication(): void + public static function authentication(): array { global $CFG_GLPI; @@ -85,6 +85,8 @@ public static function authentication(): void $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); + + return [$httpcode, $result]; } /** diff --git a/templates/config.html.twig b/templates/config.html.twig index 7c04834..8316455 100644 --- a/templates/config.html.twig +++ b/templates/config.html.twig @@ -43,61 +43,64 @@ {% set params = params ?? [] %} {% set field_options = {'full_width': true} %} -
-
-
-
-
- - +
+
+ + - {% if item.isfield('server') %} - {{ fields.textField( - 'server', - item.fields['server'], - __("Server"), - field_options - ) }} - {% endif %} + {% if item.isfield('server') %} + {{ fields.textField( + 'server', + item.fields['server'], + __("Server"), + field_options + ) }} + {% endif %} - {% if item.isfield('email') %} - {{ fields.textField( - 'email', - item.fields['email'], - __("Email"), - field_options - ) }} - {% endif %} + {% if item.isfield('email') %} + {{ fields.textField( + 'email', + item.fields['email'], + __("Email"), + field_options + ) }} + {% endif %} - {% if item.isField('apikey') %} - {{ fields.passwordField( - 'apikey', - item.fields['apikey'], - __('API key', 'onetimesecret'), - field_options - ) }} - {% endif %} + {% if item.isField('apikey') %} + {{ fields.passwordField( + 'apikey', + item.fields['apikey'], + __('API key', 'onetimesecret'), + field_options + ) }} + {% endif %} -
- - {{__('Lifetime', 'onetimesecret')}} -
+
+ + {{__('Lifetime', 'onetimesecret')}} +
- {% if item.isField('lifetime') %} - {{ fields.dropdownArrayField( - 'lifetime', - item.fields['lifetime'], - lifetimes, - __('Secret lifetime', 'onetimesecret'), - field_options|merge({'width': 'auto'}) - ) }} - {% endif %} + {% if item.isField('lifetime') %} + {{ fields.dropdownArrayField( + 'lifetime', + item.fields['lifetime'], + lifetimes, + __('Secret lifetime', 'onetimesecret'), + field_options|merge({'width': 'auto'}) + ) }} + {% endif %} +
+
-
{# .row #} -
{# .row #} -
{# .flex-row #} -
{# .flex-column #} -
{# .flex-wrap #} +
+ {% if conn and conn[0] matches '{^2\d{2}}' %} + + {% else %} + + {% endif %} +
{{ include('components/form/buttons.html.twig') }} \ No newline at end of file