Merge pull request #8014 from demarches-simplifiees/list_and_delete_linked_fci
Feat(FranceConnect): liste les comptes FC liées et permet de les délier
This commit is contained in:
commit
21bd58d6fc
6 changed files with 121 additions and 18 deletions
|
@ -4,6 +4,7 @@ module Users
|
|||
before_action :find_transfers, only: [:show, :renew_api_token]
|
||||
|
||||
def show
|
||||
@france_connect_informations = FranceConnectInformation.where(user: current_user)
|
||||
end
|
||||
|
||||
def renew_api_token
|
||||
|
@ -57,6 +58,17 @@ module Users
|
|||
redirect_to profil_path
|
||||
end
|
||||
|
||||
def destroy_fci
|
||||
fci = FranceConnectInformation
|
||||
.where(user: current_user)
|
||||
.find(params[:fci_id])
|
||||
|
||||
fci.destroy!
|
||||
flash.notice = "Le compte FranceConnect de « #{fci.full_name} » ne peut plus accéder à vos dossiers"
|
||||
|
||||
redirect_to profil_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_transfers
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
- content_for(:title, t('.profile'))
|
||||
|
||||
= render partial: 'administrateurs/breadcrumbs',
|
||||
locals: { steps: [['Tableau de bord', tableau_de_bord_helper_path],
|
||||
['Profil']] }
|
||||
[t('.profile')]] }
|
||||
|
||||
#profil-page.container
|
||||
%h1 Profil
|
||||
%h1= t('.profile')
|
||||
|
||||
- if @waiting_merge_emails.present?
|
||||
.card
|
||||
|
@ -12,23 +14,23 @@
|
|||
Acceptez-vous d’absorber le compte de
|
||||
%span.email-address= @waiting_merge_emails.join(', ')
|
||||
|
||||
= link_to 'Refuser la fusion', refuse_merge_path, method: :post, class: 'button', data: { confirm: "Confirmez-vous le refus ?" }
|
||||
= link_to 'Accepter la fusion', accept_merge_path, method: :post, class: 'button', data: { confirm: "Confirmez-vous la fusion des comptes ?" }
|
||||
= link_to 'Refuser la fusion', refuse_merge_path, method: :post, class: 'fr-btn fr-btn--secondary', data: { confirm: "Confirmez-vous le refus ?" }
|
||||
= link_to 'Accepter la fusion', accept_merge_path, method: :post, class: 'fr-btn fr-btn--secondary', data: { confirm: "Confirmez-vous la fusion des comptes ?" }
|
||||
|
||||
.card
|
||||
.card-title Coordonnées
|
||||
.card-title= t('.contact')
|
||||
%p
|
||||
Votre email est actuellement
|
||||
= t('.your_email')
|
||||
%span.email-address= current_user.email
|
||||
|
||||
- waiting_email = current_user.unconfirmed_email || current_user.requested_merge_into&.email
|
||||
|
||||
- if waiting_email.present?
|
||||
%p.mb-4
|
||||
Changement en attente :
|
||||
= t('.pending_change')
|
||||
%span.email-address= waiting_email
|
||||
%br
|
||||
Pour finaliser votre changement d’adresse, vérifiez vos emails et cliquez sur le lien de confirmation.
|
||||
= t('.finalize_email_change')
|
||||
|
||||
- if current_user.instructeur?
|
||||
%p.mb-4
|
||||
|
@ -38,8 +40,8 @@
|
|||
legit_admin_domains: LEGIT_ADMIN_DOMAINS.join(', '))
|
||||
|
||||
= form_for current_user, url: update_email_path, method: :patch, html: { class: 'form' } do |f|
|
||||
= f.email_field :email, value: nil, placeholder: 'Nouvelle adresse email', required: true
|
||||
= f.submit "Changer mon adresse", class: 'button primary'
|
||||
= f.email_field :email, value: nil, placeholder: t('.new_email_address'), required: true
|
||||
= f.submit t('.change_address'), class: 'fr-btn fr-btn--secondary'
|
||||
|
||||
- if !instructeur_signed_in?
|
||||
.card
|
||||
|
@ -48,7 +50,7 @@
|
|||
|
||||
= form_tag transfer_all_dossiers_path, class: 'form' do
|
||||
= email_field_tag :next_owner, nil, required: true
|
||||
= submit_tag "Transférer tous mes dossiers", class: 'button primary', data: { confirm: t('.transfer_confirmation') }
|
||||
= submit_tag t('.transfer_my_files'), class: 'fr-btn fr-btn--secondary', data: { confirm: t('.transfer_confirmation') }
|
||||
|
||||
- if @waiting_transfers.present?
|
||||
.card.warning
|
||||
|
@ -73,6 +75,20 @@
|
|||
= link_to "Regénérer et afficher mon jeton",
|
||||
renew_api_token_path,
|
||||
method: :post,
|
||||
class: "button primary",
|
||||
class: "fr-btn fr-btn--secondary",
|
||||
data: { confirm: "Confirmez-vous la regénération de votre jeton ? Les applications qui l’utilisent actuellement seront bloquées.",
|
||||
disable: true }
|
||||
|
||||
- if @france_connect_informations.present?
|
||||
.card
|
||||
.card-title= t('.identities', count: @france_connect_informations.count, application_name: APPLICATION_NAME)
|
||||
%p= t('.linked_identities', count: @france_connect_informations.count, application_name: APPLICATION_NAME)
|
||||
%ul
|
||||
- @france_connect_informations.each do |fci|
|
||||
%li
|
||||
#{fci.given_name} #{fci.family_name} (#{fci.email_france_connect})
|
||||
= link_to t('.forbid_access'),
|
||||
france_connect_information_path(fci_id: fci.id),
|
||||
method: :delete,
|
||||
data: { confirm: t('.unlink_confirmation', full_name: fci.full_name) },
|
||||
class: 'fr-btn fr-btn--secondary fr-ml-2w'
|
||||
|
|
45
config/locales/views/users/profil/en.yml
Normal file
45
config/locales/views/users/profil/en.yml
Normal file
|
@ -0,0 +1,45 @@
|
|||
en:
|
||||
users:
|
||||
profil:
|
||||
show:
|
||||
profile: Profile
|
||||
contact: Contact Information
|
||||
your_email: Your current email is
|
||||
new_email_address: New email address
|
||||
change_address: Change my address
|
||||
transfer_title: Transfer all your files
|
||||
transfer_explication_html: "<p>This feature allows you to change the owner of all your files. This is usually useful when changing jobs or if you want to merge several accounts.</p>
|
||||
<p>Email address of the recipient of all your files</p>"
|
||||
waiting_transfers: "Pending Transfers :"
|
||||
one_waiting_transfer:
|
||||
one: "The new owner %{email} must confirm the transfer of a file by following the instructions received in their email."
|
||||
other: "The new owner %{email} must confirm the transfer of your %{count} files by following the instructions received in their email."
|
||||
transfer_confirmation: "Do you accept the transfer?"
|
||||
transfer_my_files: Transfer all my files
|
||||
pending_change: 'Pending change:'
|
||||
finalize_email_change: To finalise your change of email address, check your emails and click on the confirmation link.
|
||||
email_explications_html: >
|
||||
<b class="bold">%{application_name}</b> must ensure that your account is used for professional purposes.
|
||||
<br>
|
||||
<br>
|
||||
We can only automatically allow email changes to the following domains:
|
||||
<br>
|
||||
%{legit_admin_domains}
|
||||
<br>
|
||||
<br>
|
||||
If this is not the case for you, contact support:
|
||||
<a href="mailto:%{contact_email}">%{contact_email}</a>
|
||||
identities:
|
||||
one: FranceConnect Identity
|
||||
other: FranceConnect Identities
|
||||
linked_identities:
|
||||
one: 'Your account on %{application_name} is currently linked to the following identity:'
|
||||
other: 'Your account on %{application_name} is currently linked to the following %{count} identities:'
|
||||
unlink_confirmation: 'the FranceConnect account "%{full_name}" will no longer be able to access your files.'
|
||||
forbid_access: forbid access
|
||||
ensure_update_email_is_authorized:
|
||||
email_not_allowed: "The email %{requested_email} cannot be used, contact support: <a href='mailto:%{contact_email}'>%{contact_email}</a>"
|
||||
transfer_all_dossiers:
|
||||
new_transfer:
|
||||
one: "The transfer of a file to %{email} is in progress"
|
||||
other: "The transfer of %{count} files to %{email} is in progress"
|
|
@ -2,28 +2,44 @@ fr:
|
|||
users:
|
||||
profil:
|
||||
show:
|
||||
profile: Profil
|
||||
contact: Coordonnées
|
||||
new_email_address: Nouvelle adresse email
|
||||
your_email: Votre email est actuellement
|
||||
change_address: Changer mon adresse
|
||||
transfer_title: Transferer tous vos dossiers
|
||||
transfer_explication_html: "<p>Cette fonctionnalité vous permet de changer le propriétaire de tous vos dossiers. C'est généralement utile lors d'un changement de poste ou si vous souhaitez fusionner plusieurs comptes.</p>
|
||||
transfer_explication_html: "<p>Cette fonctionnalité vous permet de changer le propriétaire de tous vos dossiers. C’est généralement utile lors d’un changement de poste ou si vous souhaitez fusionner plusieurs comptes.</p>
|
||||
<p>Adresse email du destinataire de tous vos dossiers</p>"
|
||||
waiting_transfers: "Transfert en attente :"
|
||||
one_waiting_transfer:
|
||||
one: "Le nouveau propriétaire %{email} doit confirmer le transfert d'un dossier en suivant les instructions reçues dans son mail."
|
||||
one: "Le nouveau propriétaire %{email} doit confirmer le transfert d’un dossier en suivant les instructions reçues dans son mail."
|
||||
other: "Le nouveau propriétaire %{email} doit confirmer le transfert de vos %{count} dossiers en suivant les instructions reçues dans son mail."
|
||||
transfer_confirmation: "Confirmez-vous le transfert ?"
|
||||
transfer_my_files: Transférer tous mes dossiers
|
||||
pending_change: 'Changement en attente :'
|
||||
finalize_email_change: Pour finaliser votre changement d’adresse, vérifiez vos emails et cliquez sur le lien de confirmation.
|
||||
email_explications_html: >
|
||||
<b class="bold">%{application_name}</b> doit s'assurer que votre compte est utilisé dans un cadre professionnel.
|
||||
<b class="bold">%{application_name}</b> doit s’assurer que votre compte est utilisé dans un cadre professionnel.
|
||||
<br>
|
||||
<br>
|
||||
Nous pouvons autoriser automatiquement les changements d'email vers les domaines suivants :
|
||||
Nous pouvons autoriser automatiquement les changements d’email vers les domaines suivants :
|
||||
<br>
|
||||
%{legit_admin_domains}
|
||||
<br>
|
||||
<br>
|
||||
Si ce n'est pas votre cas, contactez le support :
|
||||
Si ce n’est pas votre cas, contactez le support :
|
||||
<a href="mailto:%{contact_email}">%{contact_email}</a>
|
||||
identities:
|
||||
one: Identité FranceConnect
|
||||
other: Identités FranceConnect
|
||||
linked_identities:
|
||||
one: 'Votre compte sur %{application_name} est actuellement lié à l’identité suivante :'
|
||||
other: 'Votre compte sur %{application_name} est actuellement lié aux %{count} identité suivantes :'
|
||||
unlink_confirmation: 'le compte FranceConnect « %{full_name} » ne pourra plus accéder à vos dossiers.'
|
||||
forbid_access: Interdire l’accès
|
||||
ensure_update_email_is_authorized:
|
||||
email_not_allowed: "L’email %{requested_email} ne peut être utilisé, contactez le support : <a href='mailto:%{contact_email}'>%{contact_email}</a>"
|
||||
transfer_all_dossiers:
|
||||
new_transfer:
|
||||
one: "Le transfert d'un dossier à %{email} est en cours"
|
||||
one: "Le transfert d’un dossier à %{email} est en cours"
|
||||
other: "Le transfert de %{count} dossiers à %{email} est en cours"
|
||||
|
|
|
@ -311,6 +311,7 @@ Rails.application.routes.draw do
|
|||
post 'transfer_all_dossiers' => 'profil#transfer_all_dossiers'
|
||||
post 'accept_merge' => 'profil#accept_merge'
|
||||
post 'refuse_merge' => 'profil#refuse_merge'
|
||||
delete 'france_connect_information' => 'profil#destroy_fci'
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -188,4 +188,17 @@ describe Users::ProfilController, type: :controller do
|
|||
expect(response).to redirect_to(profil_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'DELETE #destroy_fci' do
|
||||
let!(:fci) { create(:france_connect_information, user: user) }
|
||||
|
||||
subject { delete :destroy_fci, params: { fci_id: fci.id } }
|
||||
|
||||
it do
|
||||
expect(FranceConnectInformation.where(user: user).count).to eq(1)
|
||||
subject
|
||||
expect(FranceConnectInformation.where(user: user).count).to eq(0)
|
||||
expect(response).to redirect_to(profil_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue