diff --git a/app/components/procedure/errors_summary.rb b/app/components/procedure/errors_summary.rb index ff1dfc8aa..6eb065052 100644 --- a/app/components/procedure/errors_summary.rb +++ b/app/components/procedure/errors_summary.rb @@ -47,6 +47,8 @@ class Procedure::ErrorsSummary < ApplicationComponent when :initiated_mail, :received_mail, :closed_mail, :refused_mail, :without_continuation_mail, :re_instructed_mail klass = "Mails::#{error.attribute.to_s.classify}".constantize edit_admin_procedure_mail_template_path(@procedure, klass.const_get(:SLUG)) + when :api_entreprise_token + jeton_admin_procedure_path(@procedure) end end diff --git a/app/models/concerns/api_entreprise_token_concern.rb b/app/models/concerns/api_entreprise_token_concern.rb index ad1d0a41e..debb559c6 100644 --- a/app/models/concerns/api_entreprise_token_concern.rb +++ b/app/models/concerns/api_entreprise_token_concern.rb @@ -7,6 +7,7 @@ module APIEntrepriseTokenConcern included do validates :api_entreprise_token, jwt_token: true, allow_blank: true + validate :api_entreprise_token_expiration_valid?, on: [:publication] before_save :set_api_entreprise_token_expires_at, if: :will_save_change_to_api_entreprise_token? @@ -18,6 +19,12 @@ module APIEntrepriseTokenConcern self[:api_entreprise_token].presence || Rails.application.secrets.api_entreprise[:key] end + def api_entreprise_token_expiration_valid? + if api_entreprise_token_expired_or_expires_soon? + errors.add(:api_entreprise_token, "expiré ou expirant bientôt") + end + end + def api_entreprise_token_expired? APIEntrepriseToken.new(api_entreprise_token).expired? end diff --git a/config/locales/models/procedure/en.yml b/config/locales/models/procedure/en.yml index 1328196b5..489d0baa0 100644 --- a/config/locales/models/procedure/en.yml +++ b/config/locales/models/procedure/en.yml @@ -48,6 +48,7 @@ en: personne_morale: 'Legal entity' declarative_with_state/en_instruction: Instruction declarative_with_state/accepte: Accepted + api_entreprise_token: Token API Entreprise api_particulier_token: Token API Particulier initiated_mail: File sorted for processing notification email received_mail: File submitted notification email diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index 35713d133..6a020049f 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -54,6 +54,7 @@ fr: personne_morale: 'Personne morale' declarative_with_state/en_instruction: En instruction declarative_with_state/accepte: Accepté + api_entreprise_token: Jeton API Entreprise api_particulier_token: Jeton API Particulier initiated_mail: L’email de notification de passage de dossier en instruction received_mail: L’email de notification de dépôt de dossier