dossier_controller#new uses info from FC if any

This commit is contained in:
clemkeirua 2019-07-31 15:49:18 +02:00
parent a181210651
commit 707e8a0004
2 changed files with 12 additions and 0 deletions

View file

@ -223,6 +223,10 @@ module Users
dossier = Dossier.create!(procedure: procedure, user: current_user, state: Dossier.states.fetch(:brouillon))
if dossier.procedure.for_individual
if current_user.france_connect_information.present?
dossier.update_with_france_connect(current_user.france_connect_information)
end
redirect_to identite_dossier_path(dossier)
else
redirect_to siret_dossier_path(id: dossier.id)

View file

@ -477,6 +477,14 @@ class Dossier < ApplicationRecord
!PiecesJustificativesService.liste_pieces_justificatives(self).empty? && PiecesJustificativesService.pieces_justificatives_total_size(self) < Dossier::TAILLE_MAX_ZIP
end
def update_with_france_connect(fc_information)
self.individual = Individual.create(
nom: fc_information.given_name,
prenom: fc_information.family_name,
gender: fc_information.gender == 'female' ? 'Mme' : 'M.'
)
end
private
def log_dossier_operation(author, operation, subject = nil)