Merge pull request #8771 from demarches-simplifiees/deprecate_old_token
déprécie les jetons d'api v1 / v2
This commit is contained in:
commit
297ac4259f
5 changed files with 54 additions and 0 deletions
|
@ -2,6 +2,11 @@
|
||||||
%b= "#{@api_token.name} "
|
%b= "#{@api_token.name} "
|
||||||
%span.fr-text--sm= @api_token.prefix
|
%span.fr-text--sm= @api_token.prefix
|
||||||
|
|
||||||
|
-# TODO: remove after 01/07/2023
|
||||||
|
- if @api_token.version != 3 && Time.zone.now < Time.zone.parse('01/07/2023')
|
||||||
|
.fr-alert.fr-alert--info.fr-alert--sm.mt-2
|
||||||
|
%p Attention, ce jeton ne sera plus valide à partir du 01/07/2023
|
||||||
|
|
||||||
.fr-card__desc
|
.fr-card__desc
|
||||||
- if @packed_token.present?
|
- if @packed_token.present?
|
||||||
.fr-text--sm{ style: "width: 80%; word-break: break-all;" }
|
.fr-text--sm{ style: "width: 80%; word-break: break-all;" }
|
||||||
|
|
|
@ -22,6 +22,15 @@ class AdministrateurMailer < ApplicationMailer
|
||||||
reply_to: CONTACT_EMAIL)
|
reply_to: CONTACT_EMAIL)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def api_token_expiration(user, tokens)
|
||||||
|
@subject = "Renouvellement de jeton d'API nécessaire"
|
||||||
|
@tokens = tokens
|
||||||
|
|
||||||
|
mail(to: user.email,
|
||||||
|
subject: @subject,
|
||||||
|
reply_to: CONTACT_EMAIL)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def forced_delivery_for_action?
|
def forced_delivery_for_action?
|
||||||
|
|
19
app/views/administrateur_mailer/api_token_expiration.haml
Normal file
19
app/views/administrateur_mailer/api_token_expiration.haml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
- content_for(:title, @subject)
|
||||||
|
|
||||||
|
%p
|
||||||
|
Bonjour,
|
||||||
|
|
||||||
|
%p
|
||||||
|
- if @tokens.one?
|
||||||
|
<b>Votre jeton d'API « #{@tokens.first.prefix} » expirera le 1er juillet 2023</b>.
|
||||||
|
- else
|
||||||
|
<b>Vos jetons d'API « #{@tokens.map(&:prefix).join(', ')} » expireront le 1er juillet 2023</b>.
|
||||||
|
Passée cette date, vos interconnexions utilisant ce jeton ne marcheront plus.
|
||||||
|
|
||||||
|
%p
|
||||||
|
Vous devrez le(s) remplacer par de nouveaux jetons que vous pouvez obtenir en utilisant la page #{link_to(profil_url, profil_url)}.
|
||||||
|
|
||||||
|
%p
|
||||||
|
Nous restons à votre disposition si vous avez besoin d’accompagnement à l'adresse #{link_to CONTACT_EMAIL, "mailto:#{CONTACT_EMAIL}"}.
|
||||||
|
|
||||||
|
= render partial: "layouts/mailers/signature"
|
15
lib/tasks/token_expiration_email.rake
Normal file
15
lib/tasks/token_expiration_email.rake
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
require Rails.root.join("lib", "tasks", "task_helper")
|
||||||
|
|
||||||
|
namespace :token_expiration_email do
|
||||||
|
task send_warning: :environment do
|
||||||
|
admin_tokens = APIToken
|
||||||
|
.includes(:administrateur)
|
||||||
|
.where(version: [1, 2])
|
||||||
|
.to_a
|
||||||
|
.group_by(&:administrateur)
|
||||||
|
|
||||||
|
admin_tokens.each do |admin, tokens|
|
||||||
|
AdministrateurMailer.api_token_expiration(admin.user, tokens).deliver_later
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,4 +10,10 @@ class AdministrateurMailerPreview < ActionMailer::Preview
|
||||||
procedure = Procedure.first
|
procedure = Procedure.first
|
||||||
AdministrateurMailer.notify_procedure_expires_when_termine_forced(email, procedure)
|
AdministrateurMailer.notify_procedure_expires_when_termine_forced(email, procedure)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def api_token_expiration
|
||||||
|
user = User.last
|
||||||
|
tokens = [APIToken.last, APIToken.last]
|
||||||
|
AdministrateurMailer.api_token_expiration(user, tokens)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue