Skip to content

Commit

Permalink
check credentials dot
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancisTicgal committed Feb 16, 2024
1 parent 3c13145 commit cc267b5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 52 deletions.
3 changes: 2 additions & 1 deletion inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions inc/secret.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -85,6 +85,8 @@ public static function authentication(): void
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

curl_close($curl);

return [$httpcode, $result];
}

/**
Expand Down
101 changes: 52 additions & 49 deletions templates/config.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,61 +43,64 @@
{% set params = params ?? [] %}
{% set field_options = {'full_width': true} %}

<div class="card-body d-flex flex-wrap">
<div class="col-12 col-xxl-12 flex-column">
<div class="d-flex flex-row flex-wrap flex-xl-nowrap">
<div class="row flex-row align-items-start flex-grow-1">
<div class="row flex-row">
<input type="hidden" name="_glpi_csrf_token" value="{{ csrf_token() }}" />
<input type="hidden" name="id" value="{{item.fields['id']}}" />
<div class="row">
<div class="row ps-4">
<input type="hidden" name="_glpi_csrf_token" value="{{ csrf_token() }}" />
<input type="hidden" name="id" value="{{item.fields['id']}}" />

{% 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 %}

<div class="hr-text">
<i class="fa fa-stopwatch"></i>
<span>{{__('Lifetime', 'onetimesecret')}}</span>
</div>
<div class="hr-text">
<i class="fa fa-stopwatch"></i>
<span>{{__('Lifetime', 'onetimesecret')}}</span>
</div>

{% 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 %}
</div>
</div>

</div> {# .row #}
</div> {# .row #}
</div> {# .flex-row #}
</div> {# .flex-column #}
</div> {# .flex-wrap #}
<div class="form-field row col-12 mt-2">
{% if conn and conn[0] matches '{^2\d{2}}' %}
<label class="form-label text-xxl-end">{{__('Connection established','onetimesecret')}}
<i class="fa fa-circle" style="color: #23E767;"></i></label>
{% else %}
<label class="form-label text-xxl-end">{{__('Check credentials','onetimesecret')}}
<i class="fa fa-circle" style="color: #E72323;"></i></label>
{% endif %}
</div>

{{ include('components/form/buttons.html.twig') }}
</div>

0 comments on commit cc267b5

Please sign in to comment.