[#10799] Add error on procedure#show if api entreprise token is expiring
This commit is contained in:
parent
99a1b68185
commit
64297f9ee8
4 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue