Merge pull request #10800 from demarches-simplifiees/fix-10798
[#10798] ETQ Superadmin, je veux savoir sur le Manager si une démarche a un jeton d'api entreprise configuré
This commit is contained in:
commit
b4ed11c788
3 changed files with 28 additions and 0 deletions
|
@ -29,6 +29,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
||||||
updated_at: Field::DateTime,
|
updated_at: Field::DateTime,
|
||||||
for_individual: Field::Boolean,
|
for_individual: Field::Boolean,
|
||||||
auto_archive_on: Field::DateTime,
|
auto_archive_on: Field::DateTime,
|
||||||
|
api_entreprise_token: JwtField,
|
||||||
published_at: Field::DateTime,
|
published_at: Field::DateTime,
|
||||||
unpublished_at: Field::DateTime,
|
unpublished_at: Field::DateTime,
|
||||||
hidden_at: Field::DateTime,
|
hidden_at: Field::DateTime,
|
||||||
|
@ -100,6 +101,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
||||||
:published_types_de_champ_public,
|
:published_types_de_champ_public,
|
||||||
:published_types_de_champ_private,
|
:published_types_de_champ_private,
|
||||||
:for_individual,
|
:for_individual,
|
||||||
|
:api_entreprise_token,
|
||||||
:auto_archive_on,
|
:auto_archive_on,
|
||||||
:passer_en_construction_email_template,
|
:passer_en_construction_email_template,
|
||||||
:passer_en_instruction_email_template,
|
:passer_en_instruction_email_template,
|
||||||
|
|
25
app/fields/jwt_field.rb
Normal file
25
app/fields/jwt_field.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "administrate/field/base"
|
||||||
|
|
||||||
|
class JwtField < Administrate::Field::Base
|
||||||
|
def to_s
|
||||||
|
if data.present?
|
||||||
|
begin
|
||||||
|
decoded_token = JWT.decode(data, nil, false)
|
||||||
|
|
||||||
|
return "Token présent, sans expiration" unless decoded_token[0].key?('exp')
|
||||||
|
|
||||||
|
if expiration < Time.zone.now
|
||||||
|
"Token présent, expiré le #{expiration.strftime('%d/%m/%Y à %H:%M')}"
|
||||||
|
else
|
||||||
|
"Token présent, expirera le #{expiration.strftime('%d/%m/%Y à %H:%M')}"
|
||||||
|
end
|
||||||
|
rescue JWT::DecodeError => e
|
||||||
|
"Token invalide : #{e.message}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
"Pas de token"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
1
app/views/fields/jwt_field/_show.html.erb
Normal file
1
app/views/fields/jwt_field/_show.html.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= field.to_s %>
|
Loading…
Reference in a new issue